-  
-   Notifications  You must be signed in to change notification settings 
- Fork 19.2k
Closed
Labels
EnhancementNeeds DiscussionRequires discussion from core team before further actionRequires discussion from core team before further actionReshapingConcat, Merge/Join, Stack/Unstack, ExplodeConcat, Merge/Join, Stack/Unstack, Explode
Milestone
Description
When we use DataFrame.explode right now, it will repeat the index for each element in the iterator. To keep it consistent with the methods like DataFrame.sort_values, DataFrame.append and pd.concat, we can add an argument ignore_index, which will reset the index.
df = pd.DataFrame({'id':range(0,30,10), 'values':[list('abc'), list('def'), list('ghi')]}) print(df) id values 0 0 [a, b, c] 1 10 [d, e, f] 2 20 [g, h, i] print(df.explode('values')) id values 0 0 a 0 0 b 0 0 c 1 10 d 1 10 e 1 10 f 2 20 g 2 20 h 2 20 iExpected behaviour with addition of the argument:
df.explode('values', ignore_index=True) id values 0 0 a 1 0 b 2 0 c 3 10 d 4 10 e 5 10 f 6 20 g 7 20 h 8 20 iMetadata
Metadata
Assignees
Labels
EnhancementNeeds DiscussionRequires discussion from core team before further actionRequires discussion from core team before further actionReshapingConcat, Merge/Join, Stack/Unstack, ExplodeConcat, Merge/Join, Stack/Unstack, Explode