从已经重采样的系列中获取规则
Get the rule from an already resampled series
我正在编写一个必须接收重采样系列作为参数的函数。我需要知道重采样规则是什么。
例如让我们来一个系列:
0 2011-01-01 00:00:00
1 2011-01-01 00:30:00
2 2011-01-01 01:00:00
3 2011-01-01 01:30:00
4 2011-01-01 02:00:00
我需要一种方法,让我在输入 s 时 returns '6H'。
使用 Series.dt.freq
但必须指定频率,而不是 None
:
print (s.dt.freq)
30T
如果有 DatetimeIndex
则使用 DatetimeIndex.freq
或
DatetimeIndex.freqstr
:
print (s.index.freq)
print (s.index.freqstr)
我正在编写一个必须接收重采样系列作为参数的函数。我需要知道重采样规则是什么。
例如让我们来一个系列:
0 2011-01-01 00:00:00
1 2011-01-01 00:30:00
2 2011-01-01 01:00:00
3 2011-01-01 01:30:00
4 2011-01-01 02:00:00
我需要一种方法,让我在输入 s 时 returns '6H'。
使用 Series.dt.freq
但必须指定频率,而不是 None
:
print (s.dt.freq)
30T
如果有 DatetimeIndex
则使用 DatetimeIndex.freq
或
DatetimeIndex.freqstr
:
print (s.index.freq)
print (s.index.freqstr)