Skip to content

Commit

Permalink
TST: validation tests for resample/groupby preservation
Browse files Browse the repository at this point in the history
closes #12202

Author: Jeff Reback <[email protected]>

Closes #12314 from jreback/resample and squashes the following commits:

bde178a [Jeff Reback] TST: validation tests for resample/groupby preservation
  • Loading branch information
jreback committed Feb 12, 2016
1 parent 0181ef4 commit 311b9a9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v0.18.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ other anchored offsets like ``MonthBegin`` and ``YearBegin``.
Resample API
^^^^^^^^^^^^

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`).
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`).

.. ipython:: python

Expand Down
18 changes: 18 additions & 0 deletions pandas/tseries/tests/test_resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 311b9a9

Please sign in to comment.