diff --git a/doc/source/whatsnew/v0.18.0.txt b/doc/source/whatsnew/v0.18.0.txt index 2dcb3fbbd5a0d..bc96a0ea30443 100644 --- a/doc/source/whatsnew/v0.18.0.txt +++ b/doc/source/whatsnew/v0.18.0.txt @@ -574,7 +574,7 @@ other anchored offsets like ``MonthBegin`` and ``YearBegin``. Resample API ^^^^^^^^^^^^ -Like the change in the window functions API :ref:`above `, ``.resample(...)`` is changing to have a more groupby-like API. (:issue:`11732`, :issue:`12702`). +Like the change in the window functions API :ref:`above `, ``.resample(...)`` is changing to have a more groupby-like API. (:issue:`11732`, :issue:`12702`, :issue:`12202`). .. ipython:: python diff --git a/pandas/tseries/tests/test_resample.py b/pandas/tseries/tests/test_resample.py index 1cece8b060377..4e2d596681942 100644 --- a/pandas/tseries/tests/test_resample.py +++ b/pandas/tseries/tests/test_resample.py @@ -1220,6 +1220,24 @@ def test_resample_empty(self): # (ex: doing mean with dtype of np.object) pass + def test_resample_dtype_preservation(self): + + # GH 12202 + # validation tests for dtype preservation + + df = DataFrame({'date': pd.date_range(start='2016-01-01', + periods=4, freq='W'), + 'group': [1, 1, 2, 2], + 'val': Series([5, 6, 7, 8], + dtype='int32')} + ).set_index('date') + + result = df.resample('1D').ffill() + self.assertEqual(result.val.dtype, np.int32) + + result = df.groupby('group').resample('1D').ffill() + self.assertEqual(result.val.dtype, np.int32) + def test_weekly_resample_buglet(self): # #1327 rng = date_range('1/1/2000', freq='B', periods=20)