From e7eadd37611908c0b78d69cc8235a477c14c3cb8 Mon Sep 17 00:00:00 2001 From: Brock Date: Sun, 15 Aug 2021 08:39:57 -0700 Subject: [PATCH 1/2] REGR: 42390 --- doc/source/whatsnew/v1.3.2.rst | 1 + pandas/core/indexes/datetimelike.py | 2 +- pandas/tests/groupby/aggregate/test_aggregate.py | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v1.3.2.rst b/doc/source/whatsnew/v1.3.2.rst index 97803856c3d94..cd34e7f839a6e 100644 --- a/doc/source/whatsnew/v1.3.2.rst +++ b/doc/source/whatsnew/v1.3.2.rst @@ -26,6 +26,7 @@ Fixed regressions - Fixed regression in :func:`concat` where ``copy=False`` was not honored in ``axis=1`` Series concatenation (:issue:`42501`) - Regression in :meth:`Series.nlargest` and :meth:`Series.nsmallest` with nullable integer or float dtype (:issue:`42816`) - Fixed regression in :meth:`Series.quantile` with :class:`Int64Dtype` (:issue:`42626`) +- Fixed regression in :meth:`.GroupBy.agg` with [???] (:issue:`42390`) .. --------------------------------------------------------------------------- diff --git a/pandas/core/indexes/datetimelike.py b/pandas/core/indexes/datetimelike.py index b7f282e43517b..080889444f809 100644 --- a/pandas/core/indexes/datetimelike.py +++ b/pandas/core/indexes/datetimelike.py @@ -551,7 +551,7 @@ def _with_freq(self, freq): @property def _has_complex_internals(self) -> bool: # used to avoid libreduction code paths, which raise or require conversion - return False + return True def is_type_compatible(self, kind: str) -> bool: warnings.warn( diff --git a/pandas/tests/groupby/aggregate/test_aggregate.py b/pandas/tests/groupby/aggregate/test_aggregate.py index 393dc0813661f..0a693967fbb19 100644 --- a/pandas/tests/groupby/aggregate/test_aggregate.py +++ b/pandas/tests/groupby/aggregate/test_aggregate.py @@ -1259,3 +1259,18 @@ def test_groupby_index_object_dtype(): ) expected = Series([False, True], index=expected_index, name="p") tm.assert_series_equal(res, expected) + + +def test_timeseries_groupby_agg(): + # GH#43290 + + def func(ser): + if ser.isna().all(): + return None + return np.sum(ser) + + df = DataFrame([1.0], index=[pd.Timestamp("2018-01-16 00:00:00+00:00")]) + res = df.groupby(lambda x: 1).agg(func) + + expected = DataFrame([[1.0]], index=[1]) + tm.assert_frame_equal(res, expected) From c196e4ffa70dcad0887f9e76b7ab0c9941c158f7 Mon Sep 17 00:00:00 2001 From: Brock Date: Mon, 16 Aug 2021 13:41:29 -0700 Subject: [PATCH 2/2] placeholder whatsnew note --- doc/source/whatsnew/v1.3.2.rst | 1 - doc/source/whatsnew/v1.3.3.rst | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/doc/source/whatsnew/v1.3.2.rst b/doc/source/whatsnew/v1.3.2.rst index 55069a87751eb..7a9549affef00 100644 --- a/doc/source/whatsnew/v1.3.2.rst +++ b/doc/source/whatsnew/v1.3.2.rst @@ -26,7 +26,6 @@ Fixed regressions - Fixed regression in :func:`concat` where ``copy=False`` was not honored in ``axis=1`` Series concatenation (:issue:`42501`) - Regression in :meth:`Series.nlargest` and :meth:`Series.nsmallest` with nullable integer or float dtype (:issue:`42816`) - Fixed regression in :meth:`Series.quantile` with :class:`Int64Dtype` (:issue:`42626`) -- Fixed regression in :meth:`.GroupBy.agg` with [???] (:issue:`42390`) .. --------------------------------------------------------------------------- diff --git a/doc/source/whatsnew/v1.3.3.rst b/doc/source/whatsnew/v1.3.3.rst index b3cd6d00d4322..4150c042cdc55 100644 --- a/doc/source/whatsnew/v1.3.3.rst +++ b/doc/source/whatsnew/v1.3.3.rst @@ -15,7 +15,7 @@ including other versions of pandas. Fixed regressions ~~~~~~~~~~~~~~~~~ - Performance regression in :meth:`core.window.ewm.ExponentialMovingWindow.mean` (:issue:`42333`) -- +- Fixed regression in :meth:`.GroupBy.agg` incorrectly raising in some cases (:issue:`42390`) - .. ---------------------------------------------------------------------------