ValueError:The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
I have a dataframe with many columns one of which is user_id.
I try the following line of code to threshold users who have less than 10 entries in the dataframe:
myDF.groupby("user_id").filter(lambda x:len(x)>10)
The value of myDF.groupby should be a dictionary with keys as user_ids and corresponding values as lists of integers (representing restaurant codes).
But I receive the aforementioned valueError. I am unable to figure out why this is happening as this worked with previous versions of pandas (when I was working on Enthought Canopy). But recently I made the switch to anaconda by Continuum analytics and this problem seems to be occurring. Does anyone know what I might be doing wrong here?
Which version of pandas? This looks like a bug in v0.12 (the first version with filter) that was fixed in v0.13. Update with conda update pandas.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With