Skip to content

Commit bde178a

Browse files
committed
TST: validation tests for resample/groupby preservation
closes pandas-dev#12202
1 parent 0181ef4 commit bde178a

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

doc/source/whatsnew/v0.18.0.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ other anchored offsets like ``MonthBegin`` and ``YearBegin``.
574574
Resample API
575575
^^^^^^^^^^^^
576576

577-
Like the change in the window functions API :ref:`above <whatsnew_0180.enhancements.moments>`, ``.resample(...)`` is changing to have a more groupby-like API. (:issue:`11732`, :issue:`12702`).
577+
Like the change in the window functions API :ref:`above <whatsnew_0180.enhancements.moments>`, ``.resample(...)`` is changing to have a more groupby-like API. (:issue:`11732`, :issue:`12702`, :issue:`12202`).
578578

579579
.. ipython:: python
580580

pandas/tseries/tests/test_resample.py

+18
Original file line numberDiff line numberDiff line change
@@ -1220,6 +1220,24 @@ def test_resample_empty(self):
12201220
# (ex: doing mean with dtype of np.object)
12211221
pass
12221222

1223+
def test_resample_dtype_preservation(self):
1224+
1225+
# GH 12202
1226+
# validation tests for dtype preservation
1227+
1228+
df = DataFrame({'date': pd.date_range(start='2016-01-01',
1229+
periods=4, freq='W'),
1230+
'group': [1, 1, 2, 2],
1231+
'val': Series([5, 6, 7, 8],
1232+
dtype='int32')}
1233+
).set_index('date')
1234+
1235+
result = df.resample('1D').ffill()
1236+
self.assertEqual(result.val.dtype, np.int32)
1237+
1238+
result = df.groupby('group').resample('1D').ffill()
1239+
self.assertEqual(result.val.dtype, np.int32)
1240+
12231241
def test_weekly_resample_buglet(self):
12241242
# #1327
12251243
rng = date_range('1/1/2000', freq='B', periods=20)

0 commit comments

Comments
 (0)