Skip to content

Commit 3d770d3

Browse files
authored
REGR: SeriesGrouper using Timestamp index (#43054)
1 parent 5d50a24 commit 3d770d3

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
@@ -551,7 +551,7 @@ def _with_freq(self, freq):
551551
@property
552552
def _has_complex_internals(self) -> bool:
553553
# used to avoid libreduction code paths, which raise or require conversion
554-
return False
554+
return True
555555

556556
def is_type_compatible(self, kind: str) -> bool:
557557
warnings.warn(

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)