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

bug in groupby.apply?, goes away if I copy the data. #5545

Closed
hhuuggoo opened this issue Nov 19, 2013 · 1 comment · Fixed by #5554
Closed

bug in groupby.apply?, goes away if I copy the data. #5545

hhuuggoo opened this issue Nov 19, 2013 · 1 comment · Fixed by #5554
Milestone

Comments

@hhuuggoo
Copy link

Tested pandas 0.11, and 0.12, both exhibit this problem

import pandas as pd

data = pd.DataFrame({'id_field' : [100, 100, 200, 300], 'category' : ['a','b','c','c'], 'value' : [1,2,3,4]})

def filt1(x):
    if x.shape[0] == 1:
        return x.copy()
    else:
        return x[x.category == 'c']


def filt2(x):
    if x.shape[0] == 1:
        return x
    else:
        return x[x.category == 'c']

#works fine                                                                                                                                                                                                                                    
print data.groupby('id_field').apply(filt1)

#throws error                                                                                                                                                                                                                                  
print data.groupby('id_field').apply(filt2)
@jreback
Copy link
Contributor

jreback commented Nov 20, 2013

@hhuuggoo very subtle bug, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants