0

Pandas 1.1.0 Python 3.8

When i tried to read a excel file with read_excel method

the file is loaded fine, but the excel has date formatting in some columns and pandas change the format automatically

I want to avoid this behavior

  • Look at this [answer](https://stackoverflow.com/questions/16176996/keep-only-date-part-when-using-pandas-to-datetime) – Ahmet Aug 11 '20 at 03:09
  • can you `print(df.dtypes)` under the hood, the format is immaterial, a datetime is just a number - or the number of ticks since epoch. you can change the format back to default. – Umar.H Aug 11 '20 at 03:32

1 Answers1

1

You can set the dtypes parameter in read_excel function like

df=pd.read_excel('excel.xlsx', dtypes={'datecolumnname1':str, 'datecolumnnam2':str,...})
Kuldip Chaudhari
  • 1,112
  • 4
  • 8