Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

as_index is only applied to aggregators #4648

Closed
cpcloud opened this issue Aug 23, 2013 · 1 comment · Fixed by #4670
Closed

as_index is only applied to aggregators #4648

cpcloud opened this issue Aug 23, 2013 · 1 comment · Fixed by #4670
Assignees
Labels
Groupby Indexing Related to indexing on series/frames, not to indexes themselves
Milestone

Comments

@cpcloud
Copy link
Member

cpcloud commented Aug 23, 2013

as_index doesn't seem to work for non reductive operations

Note: I've only tested with head

In [7]: df = pd.DataFrame({'item_id': ['b', 'b', 'a', 'c', 'a', 'b'], 'user_id': [1,2,1,1,3,1], 'time': ra
nge(6)})

In [8]: df.groupby('user_id', as_index=False).sum()
Out[8]:
   user_id  time
0        1    10
1        2     1
2        3     4

In [9]: df.groupby('user_id', as_index=False).head()
Out[9]:
          item_id  time  user_id
user_id
1       0       b     0        1
        2       a     2        1
        3       c     3        1
        5       b     5        1
2       1       b     1        2
3       4       a     4        3

from this SO question

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Groupby Indexing Related to indexing on series/frames, not to indexes themselves
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants