Skip to content

Commit 8363092

Browse files
Backport PR #43054: REGR: SeriesGrouper using Timestamp index (#43081)
Co-authored-by: jbrockmendel <[email protected]>
1 parent eeceda8 commit 8363092

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

doc/source/whatsnew/v1.3.3.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Fixed regressions
1616
~~~~~~~~~~~~~~~~~
1717
- Fixed regression in :class:`DataFrame` constructor failing to broadcast for defined :class:`Index` and len one list of :class:`Timestamp` (:issue:`42810`)
1818
- Performance regression in :meth:`core.window.ewm.ExponentialMovingWindow.mean` (:issue:`42333`)
19-
-
19+
- Fixed regression in :meth:`.GroupBy.agg` incorrectly raising in some cases (:issue:`42390`)
2020
-
2121

2222
.. ---------------------------------------------------------------------------

pandas/core/indexes/datetimelike.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ def _with_freq(self, freq):
626626
@property
627627
def _has_complex_internals(self) -> bool:
628628
# used to avoid libreduction code paths, which raise or require conversion
629-
return False
629+
return True
630630

631631
def is_type_compatible(self, kind: str) -> bool:
632632
return kind in self._data._infer_matches

pandas/tests/groupby/aggregate/test_aggregate.py

+15
Original file line numberDiff line numberDiff line change
@@ -1259,3 +1259,18 @@ def test_groupby_index_object_dtype():
12591259
)
12601260
expected = Series([False, True], index=expected_index, name="p")
12611261
tm.assert_series_equal(res, expected)
1262+
1263+
1264+
def test_timeseries_groupby_agg():
1265+
# GH#43290
1266+
1267+
def func(ser):
1268+
if ser.isna().all():
1269+
return None
1270+
return np.sum(ser)
1271+
1272+
df = DataFrame([1.0], index=[pd.Timestamp("2018-01-16 00:00:00+00:00")])
1273+
res = df.groupby(lambda x: 1).agg(func)
1274+
1275+
expected = DataFrame([[1.0]], index=[1])
1276+
tm.assert_frame_equal(res, expected)

0 commit comments

Comments
 (0)