Reputation: 1801
I have a dataset whose exact format or origin is unknown to me. I know that the time that the data was recorded is around September 2017, and the time column contains the following numbers:
[736887.61095486],
[736887.61096065],
...,
[736905.61505787],
[736905.61506366],
Any ideas how can I convert this to proper DateTime
and use this column as my DataFrame
index?
Upvotes: 0
Views: 419
Reputation: 57033
Now that we know that your numbers represent the number of days from January 0, 0000, we can use module datetime
to reconstruct their calendar values:
import pandas as pd
from datetime import datetime, timedelta
data = ... # Your data
pd.Series(timedelta(d[0]) for d in data) + datetime(1,1,1)
#0 2018-07-13 14:39:46.499903
#1 2018-07-13 14:39:47.000162
#2 2018-07-31 14:45:40.999972
#3 2018-07-31 14:45:41.500221
Apparently, the date January 0, 0000 in Python corresponds to the year #1, month #1, and day #1.
Upvotes: 2