i decided to practice with to_datetime function , for this purpose i have changed source format of date as an integers , here is after reading excel file, how each column looks like
import numpy as np
import pandas as pd
data =pd.read_excel("pivot.xlsx")
#data["Date"] =pd.to_datetime(data["Date"],format='%d%m%y',infer_datetime_format=True)
print(data.head())
result is :
Order ID Product Category Amount Date Country
0 1 Carrots Vegetables 4270 42375 United States
1 2 Broccoli Vegetables 8239 42376 United Kingdom
2 3 Banana Fruit 617 42377 United States
3 4 Banana Fruit 8384 42379 Canada
4 5 Beans Vegetables 2626 42379 Germany
in source, dateformat of date column is following 1/6/2016 so when i have apply to_datetime function, i have got following result :
import numpy as np
import pandas as pd
data =pd.read_excel("pivot.xlsx")
data["Date"] =pd.to_datetime(data["Date"],format='%d%m%y',infer_datetime_format=True)
print(data.head())
result :
Order ID Product ... Date Country
0 1 Carrots ... 1970-01-01 00:00:00.000042375 United States
1 2 Broccoli ... 1970-01-01 00:00:00.000042376 United Kingdom
2 3 Banana ... 1970-01-01 00:00:00.000042377 United States
3 4 Banana ... 1970-01-01 00:00:00.000042379 Canada
4 5 Beans ... 1970-01-01 00:00:00.000042379 Germany
how can i fix it? in excel starting date is 1900 right? how can i apply it? is it possible to return real dates from those integers?