本文整理汇总了Python中pandas.TimeSeries.resample方法的典型用法代码示例。如果您正苦于以下问题:Python TimeSeries.resample方法的具体用法?Python TimeSeries.resample怎么用?Python TimeSeries.resample使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pandas.TimeSeries
的用法示例。
在下文中一共展示了TimeSeries.resample方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_resample_fill_missing
# 需要导入模块: from pandas import TimeSeries [as 别名]
# 或者: from pandas.TimeSeries import resample [as 别名]
def test_resample_fill_missing(self):
rng = PeriodIndex([2000, 2005, 2007, 2009], freq='A')
s = TimeSeries(np.random.randn(4), index=rng)
stamps = s.to_timestamp()
filled = s.resample('A')
expected = stamps.resample('A').to_period('A')
assert_series_equal(filled, expected)
filled = s.resample('A', fill_method='ffill')
expected = stamps.resample('A', fill_method='ffill').to_period('A')
assert_series_equal(filled, expected)
示例2: test_resample_5minute
# 需要导入模块: from pandas import TimeSeries [as 别名]
# 或者: from pandas.TimeSeries import resample [as 别名]
def test_resample_5minute(self):
rng = period_range('1/1/2000', '1/5/2000', freq='T')
ts = TimeSeries(np.random.randn(len(rng)), index=rng)
result = ts.resample('5min')
expected = ts.to_timestamp().resample('5min')
assert_series_equal(result, expected)