Skip to content

BUG: groupby with empty object, categorical grouper, and dropna=False fails #50634

New issue

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

Closed
rhshadrach opened this issue Jan 9, 2023 · 0 comments · Fixed by #50635
Closed

BUG: groupby with empty object, categorical grouper, and dropna=False fails #50634

rhshadrach opened this issue Jan 9, 2023 · 0 comments · Fixed by #50635
Assignees
Labels
Bug Categorical Categorical Data Type Groupby Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate

Comments

@rhshadrach
Copy link
Member

df = DataFrame({'a': [1, 1, 2], 'b': [3, 4, 5]})
df['a'] = df['a'].astype('category')
df = df.iloc[:0]
gb = df.groupby('a', dropna=False, observed=True)
print(gb.sum())

gives ValueError: attempt to get argmax of an empty sequence

@rhshadrach rhshadrach added Bug Groupby Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Categorical Categorical Data Type labels Jan 9, 2023
@rhshadrach rhshadrach self-assigned this Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Categorical Categorical Data Type Groupby Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant