We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
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
df = pandas.DataFrame({'a': [1, 0, 0, 0]}) df.groupby(pandas.cut(df.a, [0, 1, 2, 3, 4])).apply(lambda x: len(x)) Out[3]: a (0, 1] 1 (1, 2] 0 (2, 3] 0 (3, 4] 3 dtype: int64
final group length should be 0 not 3
The text was updated successfully, but these errors were encountered:
I recall another issue that is similar (but can't find ATM).
You can use these (and are much faster anyhow)
In [6]: df.groupby(pandas.cut(df.a, [0, 1, 2, 3, 4])).size() Out[6]: a (0, 1] 1 (1, 2] NaN (2, 3] NaN (3, 4] NaN dtype: float64 In [7]: df.groupby(pandas.cut(df.a, [0, 1, 2, 3, 4])).count() Out[7]: a a (0, 1] 1 (1, 2] 0 (2, 3] 0 (3, 4] 0
Sorry, something went wrong.
closed by #10014
No branches or pull requests
final group length should be 0 not 3
The text was updated successfully, but these errors were encountered: