Skip to content

Commit

Permalink
Fix an error with groupby value_counts and pandas 2.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
j-bennet committed Feb 10, 2023
1 parent 052a625 commit 19eab76
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion dask/dataframe/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -1543,7 +1543,17 @@ def _single_agg(
with check_numeric_only_deprecation():
meta = func(self._meta_nonempty, **chunk_kwargs)

columns = meta.name if is_series_like(meta) else meta.columns
if is_series_like(meta):
# in pandas 2.0, Series returned from value_counts have a name
# different from original object, but here, column name should
# still reflect the original object name
if func is _value_counts:
columns = self._meta.apply(pd.Series).name
else:
columns = meta.name
else:
columns = meta.columns

args = [self.obj] + (self.by if isinstance(self.by, list) else [self.by])

token = self._token_prefix + token
Expand Down

0 comments on commit 19eab76

Please sign in to comment.