Ibrahima Khalil Ibrahima Khalil - 5 months ago 10
MySQL Question

combine the date and time to create an index in times series

I load the data

df3=sql.read_sql("select * from referenceMesure",conn)
print df3


output

NumeroM Date Heure Reg
0 2396 2016-05-26 15:32:00 2396
1 2397 2016-05-26 15:34:00 75599
2 2398 2016-05-26 15:35:00 5822
3 2399 2016-05-26 15:37:00 45225
4 2400 2016-05-26 15:38:00 5266


informations

NumeroM int64
Date datetime64[ns]
Heure timedelta64[ns]


i want the columns Date and hour contain the date-time information. i.e I want

NumeroM Date Heure Reg
2016-05-26:15:32:00 2396 2016-05-26 15:32:00 2396
2016-05-26:15:34:00 2397 2016-05-26 15:34:00 75599


I want to a time series

Answer

I think you can use addition, because dtype of column Date is datetime and column Heure is timedelta:

df.index = df.Date + df.Heure
print (df)
                     NumeroM       Date    Heure    Reg
2016-05-26 15:32:00     2396 2016-05-26 15:32:00   2396
2016-05-26 15:34:00     2397 2016-05-26 15:34:00  75599
2016-05-26 15:35:00     2398 2016-05-26 15:35:00   5822
2016-05-26 15:37:00     2399 2016-05-26 15:37:00  45225
2016-05-26 15:38:00     2400 2016-05-26 15:38:00   5266