how can i convert a float64 type value into datetime type value.
here is the the first five float values from the dataset:
0 41245.0
1 41701.0
2 36361.0
3 36145.0
4 42226.0
Name: product_first_sold_date, dtype: float64
And to convert the float type to datetime type value I wrote this:
from datetime import datetime
pd.to_datetime(y['product_first_sold_date'], format='%m%d%Y.0', errors='coerce')
but as the output I got 'NaT' for all the rows in the dataset:
0 NaT
1 NaT
2 NaT
3 NaT
4 NaT
Name: product_first_sold_date, Length: 19273, dtype: datetime64[ns]
then, this:
print(pd.to_datetime(y.product_first_sold_date, infer_datetime_format=True))
but it shows the same date for all the rows in the dataset
0 1970-01-01 00:00:00.000041245
1 1970-01-01 00:00:00.000041701
2 1970-01-01 00:00:00.000036361
3 1970-01-01 00:00:00.000036145
4 1970-01-01 00:00:00.000042226
and I really can't figure out what's wrong with the code?
i have also tried this:
pd.to_datetime(pd.Series(g.product_first_sold_date).astype(str), format='%d%m%Y.0')
and got this as output I have also change the format = '%Y%m%d.0':
ValueError: time data '41245.0' does not match format '%d%m%Y.0' (match)
it looks like nothing works or may be I just did something wrong, don't know how to fix this.Thanks in advance!