Python Forum
Linear Regression on Time Series
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Linear Regression on Time Series
#6
I think there is some confusion in your understanding, but anyway

import pandas as pd
import numpy as np
df = pd.DataFrame([['2017-11-10', 4470.76], ['2017-11-11', 5465.72], ['2017-11-12', 15465.72]], columns=['Date_Time', 'eie'])
y = np.array(df['eie'], dtype=float)
x = np.array(pd.to_datetime(df['Date_Time'], format='%Y-%m-%d'), dtype='datetime64[D]')
print(y)
print(x)
Output:
[ 4470.76 5465.72 15465.72] ['2017-11-10' '2017-11-11' '2017-11-12']
or
import pandas as pd
import numpy as np
df = pd.DataFrame([['2017-11-10', 4470.76], ['2017-11-11', 5465.72], ['2017-11-12', 15465.72]], columns=['Date_Time', 'eie'])
y = np.array(df['eie'], dtype=float)
x = np.array(pd.to_datetime(df['Date_Time'].index.values+1, format='%Y-%m-%d'), dtype=int)
print(y)
print(x)
Output:
[ 4470.76 5465.72 15465.72] [1 2 3]
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
Linear Regression on Time Series - by karlito - Jan-27-2020, 02:19 PM
RE: Linear Regression on Time Series - by buran - Jan-27-2020, 02:22 PM
RE: Linear Regression on Time Series - by karlito - Jan-27-2020, 02:34 PM
RE: Linear Regression on Time Series - by buran - Jan-27-2020, 03:00 PM
RE: Linear Regression on Time Series - by karlito - Jan-28-2020, 09:20 AM
RE: Linear Regression on Time Series - by buran - Jan-28-2020, 10:02 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Simple linear regression with interaction summary table Andrzej_Andrzej 0 305 Feb-21-2024, 07:44 AM
Last Post: Andrzej_Andrzej
  Help: Conversion of Electricity Data into Time Series Data SmallGuy 3 1,240 Oct-04-2023, 03:31 PM
Last Post: deanhystad
  Time Series Production Process Problem Mzarour 1 2,142 Feb-28-2023, 12:25 PM
Last Post: get2sid
  reduce time series based on sum condition amdi40 0 1,111 Apr-06-2022, 09:09 AM
Last Post: amdi40
  How to accumulate volume of time series amdi40 3 2,327 Feb-15-2022, 02:23 PM
Last Post: amdi40
  Recommendations for ML libraries for time-series forecast AndreasPython 0 1,895 Jan-06-2021, 01:03 PM
Last Post: AndreasPython
  Time Series forecating with multiple independent variables Krychol88 1 1,880 Oct-23-2020, 08:11 AM
Last Post: DPaul
  how to handling time series data file with Python? aupres 4 3,019 Aug-10-2020, 12:40 PM
Last Post: MattKahn13
  Changing Time Series from Start to End of Month illmattic 0 1,889 Jul-16-2020, 10:49 AM
Last Post: illmattic
  HELP- DATA FRAME INTO TIME SERIES- BASIC bntayfur 0 1,770 Jul-11-2020, 09:04 PM
Last Post: bntayfur

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020