You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/Users/username/.virtualenvs/my_project/lib/python3.8/site-packages/pandas/core/groupby/generic.py", line 736, in value_counts
codes = [rep(level_codes) for level_codes in codes] + [llab(lab, inc)]
File "/Users/username/.virtualenvs/my_project/lib/python3.8/site-packages/pandas/core/groupby/generic.py", line 705, in <lambda>
llab =lambdalab, inc: lab[inc]
IndexError: boolean index did not match indexed array along dimension 0; dimension is 0 but corresponding boolean dimension is 1
Instead, I would expect that value_counts returns an empty series, like when using the max method, like the following,
rhshadrach
changed the title
QST: Why does SeriesGroupBy.value_counts() raise an error for an empty SeriesGroupBy?
BUG: SeriesGroupBy.value_counts() raises on an empty Series
Jan 15, 2021
I have searched the [pandas] tag on StackOverflow for similar questions.
I have asked my usage related question on StackOverflow.
Question about pandas
Using the
value_counts
method after grouping an empty DataFrame and selecting a column raises an error.Example:
Error:
Instead, I would expect that
value_counts
returns an empty series, like when using themax
method, like the following,which gives this result:
If it is normal to have an error when using
value_counts
for an emptySeriesGroupBy
, why is it so?Thank you.
The text was updated successfully, but these errors were encountered: