Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions pandas/tests/groupby/aggregate/test_aggregate.py
Original file line number Diff line number Diff line change
Expand Up @@ -1327,6 +1327,23 @@ def func(ser):
tm.assert_frame_equal(res, expected)


def test_groupby_aggregate_directory(reduction_func):
# GH#32793
if reduction_func not in ["corrwith", "nth"]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just do a return if the reduction_func is in rather than this big if

obj = DataFrame([[0, 1], [0, np.nan]])

obj.convert_dtypes()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what are you expecting this to do?

df_agg_last = obj.groupby(0).agg(reduction_func)
df_agg_last_dir = obj.groupby(0).agg({1: reduction_func})

if reduction_func in ["size", "ngroup"]:
tm.assert_equal(df_agg_last.values, df_agg_last_dir[1].values)
assert df_agg_last.dtypes == df_agg_last_dir[1].dtypes
else:
tm.assert_frame_equal(df_agg_last, df_agg_last_dir)
tm.assert_series_equal(df_agg_last.dtypes, df_agg_last_dir.dtypes)


def test_group_mean_timedelta_nat():
# GH43132
data = Series(["1 day", "3 days", "NaT"], dtype="timedelta64[ns]")
Expand Down