diff --git a/pandas/tests/groupby/test_groupby.py b/pandas/tests/groupby/test_groupby.py index 6783fc5b66433..087b4f64307e6 100644 --- a/pandas/tests/groupby/test_groupby.py +++ b/pandas/tests/groupby/test_groupby.py @@ -368,6 +368,7 @@ def test_attr_wrapper(ts): # get attribute result = grouped.dtype expected = grouped.agg(lambda x: x.dtype) + tm.assert_series_equal(result, expected) # make sure raises error msg = "'SeriesGroupBy' object has no attribute 'foo'" @@ -1503,7 +1504,7 @@ def test_groupby_reindex_inside_function(): ind = date_range(start="2012/1/1", freq="5min", periods=periods) df = DataFrame({"high": np.arange(periods), "low": np.arange(periods)}, index=ind) - def agg_before(hour, func, fix=False): + def agg_before(func, fix=False): """ Run an aggregate func on the subset of data. """ @@ -1518,13 +1519,9 @@ def _func(data): return _func - def afunc(data): - d = data.select(lambda x: x.hour < 11).dropna() - return np.max(d) - grouped = df.groupby(lambda x: datetime(x.year, x.month, x.day)) - closure_bad = grouped.agg({"high": agg_before(11, np.max)}) - closure_good = grouped.agg({"high": agg_before(11, np.max, True)}) + closure_bad = grouped.agg({"high": agg_before(np.max)}) + closure_good = grouped.agg({"high": agg_before(np.max, True)}) tm.assert_frame_equal(closure_bad, closure_good) diff --git a/pandas/tests/groupby/test_groupby_dropna.py b/pandas/tests/groupby/test_groupby_dropna.py index cd6c17955c18d..29a8f883f0ff5 100644 --- a/pandas/tests/groupby/test_groupby_dropna.py +++ b/pandas/tests/groupby/test_groupby_dropna.py @@ -199,7 +199,6 @@ def test_slice_groupby_then_transform(dropna, df_expected, s_expected): res = gb_slice.transform(len) tm.assert_frame_equal(res, df_expected) - gb_slice = gb["B"] res = gb["B"].transform(len) tm.assert_series_equal(res, s_expected)