def test_how_compat(self):
# in prior versions, we would allow how to be used in the resample
# now that its deprecated, we need to handle this in the actual
# aggregation functions
s = pd.Series(
np.random.randn(20),
index=pd.date_range('1/1/2000', periods=20, freq='12H'))
for how in ['min', 'max', 'median']:
for op in ['mean', 'sum', 'std', 'var', 'kurt', 'skew']:
for t in ['rolling', 'expanding']:
with tm.assert_produces_warning(FutureWarning,
check_stacklevel=False):
dfunc = getattr(pd, "{0}_{1}".format(t, op))
if dfunc is None:
continue
if t == 'rolling':
kwargs = {'window': 5}
else:
kwargs = {}
result = dfunc(s, freq='D', how=how, **kwargs)
expected = getattr(
getattr(s, t)(freq='D', **kwargs), op)(how=how)
assert_series_equal(result, expected)
test_window.py 文件源码
python
阅读 27
收藏 0
点赞 0
评论 0
评论列表
文章目录