python linear regression predict by date

前端 未结 5 1960
旧时难觅i
旧时难觅i 2021-01-01 22:34

I want to predict a value at a date in the future with simple linear regression, but I can\'t due to the date format.

This is the dataframe I have:



        
5条回答
  •  既然无缘
    2021-01-01 22:53

    convert:

    1) date to dataframe index

    df = df.set_index('date', append=False)
    

    2) convert datetime object to float64 object

    df = df.index.to_julian_date()
    

    run the regression with date being the independent variable.

提交回复
热议问题