Skip to content

element-wise iteration over subgroups fails #550

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

Closed
mattharrison opened this issue Dec 28, 2011 · 3 comments
Closed

element-wise iteration over subgroups fails #550

mattharrison opened this issue Dec 28, 2011 · 3 comments
Milestone

Comments

@mattharrison
Copy link

Am trying to iterate over elements in a subgroup of a data frame and get a keyerror:

(Pdb) [x for x in group.ix]
*** KeyError: 0
(Pdb) len(group)
7

Element-wise iteration over the parent data frame works fine.

@wesm
Copy link
Member

wesm commented Dec 28, 2011

What elements? What you wrote is not a supported part of the API:

[x for x in group.ix]

I'm actually surprised that works anywhere (I guess it works by accident)

@wesm
Copy link
Member

wesm commented Dec 28, 2011

If you want to iterate over the rows (as Series objects), I'm adding a method to do it. In the meantime, you can do;

for k in group.index:
    x = group.xs(k)

@wesm
Copy link
Member

wesm commented Jan 10, 2012

The new DataFrame.iterrows iterator (in the current revision, will be part of the 0.7.0 release) does that you're looking for I believe.

@wesm wesm closed this as completed Jan 10, 2012
dan-nadler pushed a commit to dan-nadler/pandas that referenced this issue Sep 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants