Reputation: 131
I'm trying to decompose a time series using sm.tsa.seasonal_decompose() and I got a
ValueError: You must specify a period or x must be a pandas object with a >DatetimeIndex with a freq not set to None
I followed the suggestions of the answer here: decompose() for time series: ValueError: You must specify a period or x must be a pandas object with a DatetimeIndex with a freq not set to None
So I tried setting the frequency of my time to minutes since this was the frequency with which the data was recorded. To that end, I tried the following code:
df = df.set_index('timestamp').asfreq('T')
df.index = pd.to_datetime(df.index)
Where 'T' specifies that the frequency is in minutes. But this resulted in my dataframe having only null values. How can I fix this?
Upvotes: 0
Views: 201
Reputation: 548
so your code might be a little off. Would this work
df.index = pd.to_datetime(df.index)
df.set_index('timestamp', inplace=True)
Could you share and print out the results of this?
Upvotes: 0