我必须为两个小时的数据设置什么 df.index.freq?

What df.index.freq do I have to set for two hourly data?

在进行时间序列分析时,我们需要为月度数据设置这样的频率:

df.index.freq = 'MS'

如果我有两个小时数据(或 30 天数据等),我必须设置什么频率?

非常感谢!

我认为你需要 Series.asfreq 如果需要更改频率:

df = df.asfreq('2H')

如果需要数据处理 - 例如30 天每 2 小时 sum 聚合:

df1 = df.resample('2H').sum()

df2 = df.resample('30D').sum()