We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Trying to filter out groups with less than 1 row with the new groupby().filter() in 0.12.0:
df = pd.DataFrame({'A' : ['foo', 'bar', 'foo', 'bar', ....: 'foo', 'bar', 'foo', 'foo'], ....: 'B' : ['one', 'one', 'two', 'three', ....: 'two', 'two', 'one', 'three'], ....: 'C' : np.random.randn(8), ....: 'D' : np.random.randn(8)}) grp = df.groupby(['A', 'B']) grp.apply(lambda x: len(x)>1) # Returns correct bool series A B bar one False three False two False foo one True three False two True dtype: bool grp.filter(lambda x: len(x)>1) --------------------------------------------------------------------------- ValueError Traceback (most recent call last) <ipython-input-140-4dccfb561597> in <module>() ----> 1 grp.filter(lambda x: len(x)>1) C:\Python27\lib\site-packages\pandas\core\groupby.pyc in filter(self, func, dropna, *args, **kwargs) 2092 res = path(group) 2093 -> 2094 if res: 2095 indexers.append(self.obj.index.get_indexer(group.index)) 2096 ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
The text was updated successfully, but these errors were encountered:
reported on #4447, but nice example as well!
Sorry, something went wrong.
Ahh someone beat me to it. I can close or leave it open for the example.
its linked....so going to close..thanks for the report
No branches or pull requests
Trying to filter out groups with less than 1 row with the new groupby().filter() in 0.12.0:
The text was updated successfully, but these errors were encountered: