pandas.DatetimeIndex.freqstr #
- 属性 DatetimeIndex。freqstr [来源] #
如果设置了频率对象,则将其作为字符串返回,否则返回 None。
例子
对于日期时间索引:
>>> idx = pd.DatetimeIndex(["1/1/2020 10:00:00+00:00"], freq="D") >>> idx.freqstr 'D'
如果有超过 2 个点,就可以推断出频率:
>>> idx = pd.DatetimeIndex(["2018-01-01", "2018-01-03", "2018-01-05"], ... freq="infer") >>> idx.freqstr '2D'
对于周期索引:
>>> idx = pd.PeriodIndex(["2023-1", "2023-2", "2023-3"], freq="M") >>> idx.freqstr 'M'