Reputation: 21971
When I use groupby on a pandas dataframe, an index is automatically created by the column I used for grouping. If I want to use that column later, I can do something like:
df['index1'] = df.index
Is there a way, I can use groupby and not create the index? Specifying as_index=False does not work.
Upvotes: 0
Views: 268
Reputation: 139172
Specify as_index=False
in the groupby call. See the groupby docstring.
(although it will depend on the exact operation you do on the groupby object afterwards if this will have effect or not).
Upvotes: 2