ValueError: Inferred frequency None from passed values does not conform to passed frequency MS

Viewed 3344

I am trying to create month frequency index for time series analysis The datevariable is a timestamp starts from 2018-10-18 10:50:10 till 2019-11-25 15:09:33. I am getting the error in subject line i tried removing the nulls but that did not help. New to python programming, any help

df=pd.read_excel("Source_Data.xlsx",index_col="activation date",parse_dates=True)

df.rename(
    columns={
        "activation date":"Date",
        "Estimate Volumes in HL (ABI)":"Volume"
    },
    inplace=True
)

dataset=df.filter(["Date","Volume"],axis=1)

dataset.index.freq="MS"
1 Answers

Solution:

dataset.index.asfreq('MS')

Your dataset probably has missing months. You have to fill up every instance of the chosen frequency using "asfreq". It will then automatically set the freq='MS'. You can also fix dataset.index.freq="MS" yourself but it is automatically done for you once you apply asfreq('MS').

Related