Closed
Description
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)