【问题标题】:Access to the Frequency attribute of a pd.TimeSeries访问 pd.TimeSeries 的频率属性
【发布时间】:2018-11-03 17:21:29
【问题描述】:

如何访问 pd.TimeSeries 的频率属性

例如,这里我想得到“H”:

rng = pd.date_range('1/1/2011', periods=72, freq='H')
ts = pd.Series(np.random.randn(len(rng)), index=rng)
ts.head()

2011-01-01 00:00:00    0.469112
2011-01-01 01:00:00   -0.282863
2011-01-01 02:00:00   -1.509059
2011-01-01 03:00:00   -1.135632
2011-01-01 04:00:00    1.212112
Freq: H, dtype: float64

【问题讨论】:

  • ts.index.freq

标签: python pandas time-series series


【解决方案1】:

使用DatetimeIndex.freqstr:

print (ts.index.freqstr)
H

【讨论】:

    猜你喜欢
    • 2010-11-14
    • 2016-11-27
    • 2016-05-06
    • 2019-07-05
    • 1970-01-01
    • 2015-11-03
    • 2014-10-02
    • 1970-01-01
    • 2017-02-12
    相关资源
    最近更新 更多