Skip to content

Commit 4a5605f

Browse files
committed
add tests to Series/test_constructors; and update whatsnew
1 parent 7cf1be9 commit 4a5605f

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

doc/source/whatsnew/v0.18.0.txt

+2
Original file line numberDiff line numberDiff line change
@@ -796,3 +796,5 @@ Bug Fixes
796796
- Bug in ``.skew`` and ``.kurt`` due to roundoff error for highly similar values (:issue:`11974`)
797797

798798
- Bug in ``buffer_rd_bytes`` src->buffer could be freed more than once if reading failed, causing a segfault (:issue:`12098`)
799+
800+
- Bug in ``df.resample`` on categorical data with TimedeltaIndex (:issue:`12169`)

pandas/tests/series/test_constructors.py

+18
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,24 @@ def test_constructor_dict_multiindex(self):
519519
ser = ser.reindex(index=expected.index)
520520
check(ser, expected)
521521

522+
def test_constructor_dict_timedelta_index(self):
523+
# GH #12169 : Resample category data with timedelta index
524+
# construct Series from dict as data and TimedeltaIndex as index
525+
# will result NaN in result Series data
526+
expected = Series(
527+
data=['A'] * 3,
528+
index=pd.to_timedelta([0, 10, 20], unit='s')
529+
)
530+
531+
result = Series(
532+
data={pd.to_timedelta(0, unit='s'): 'A',
533+
pd.to_timedelta(10, unit='s'): 'A',
534+
pd.to_timedelta(20, unit='s'): 'A'},
535+
index=pd.to_timedelta([0, 10, 20], unit='s')
536+
)
537+
# this should work
538+
assert_series_equal(result, expected)
539+
522540
def test_constructor_subclass_dict(self):
523541
data = tm.TestSubDict((x, 10.0 * x) for x in range(10))
524542
series = Series(data)

0 commit comments

Comments
 (0)