Tobitor
Tobitor

Reputation: 1508

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

When doing Time series Analysis we need to set a frequency like this for monthly data:

df.index.freq = 'MS'

What frequency do I have to set if I have two hourly data (or 30 days data etc.)?

Thanks a lot!

Upvotes: 1

Views: 616

Answers (1)

jezrael
jezrael

Reputation: 862521

I think you need Series.asfreq if need change frequency:

df = df.asfreq('2H')

If need data processing - e.g. aggregate by sum per 2 hours, 30 days:

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

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

Upvotes: 1

Related Questions