I have data upload in MS Excel format. enter image description here
This file has a column with dates in "dd.mm.yyyy 00:00:00" format. Reading file with code:
df = pd.read_excel('data_from_db.xlsx')
I recieve a frame, where dates column has "object" type. Further I convert this column to date format by command:
df['Date_Column'] = pd.to_datetime(df['Date_Column'])
That gives me "datetime64[ns]" type.
But this command does not work correctly each time. I meet rows with muddled data:
- somewhere rows have format "yyyy.mm.dd",
- somwhere "yyyy.dd.mm".
How should I correctly convert excel column with "dd.mm.yyyy 00:00:00" format to column in pandas dataframe with date type and "dd.mm.yyyy" fromat?
P.S. Also, I noticed this oddity: some values in raw date column have str type, another - float. But I can't wrap my head around it, because raw table is an upload from database.
data_from_db.xlsx. Have you checked the date format inside the spreadsheet, are they all'dd.mm.yyyy'?