I have the following sample data stored in Excel file
CLAIM | CODE1 | AGE | DATE |
---|---|---|---|
7538 | 359 | 71 | 28/11/2019 |
7538 | 359 | 71 | 28/11/2019 |
540 | 428 | 73 | 16/10/2019 |
540 | 428 | 73 | 16/10/2019 |
605 | 1670 | 40 | 04/12/2019 |
740 | 134 | 55 | 24/12/2019 |
When importing to my Jupyter Notebook using the pandas.read_excel API, the date field does not get properly formated:
excel = pd.read_excel('Libro.xlsx')
Then I am getting the DATE field different as I have it formatted in the excel file. What argument should I apply to read_excel
in order to display the DATE column formatted as I have it in the excel file?
.info()
method, outputs the column as int64
I already tried using the pd.to_datetime
function, but I am getting strange results:
Find the sample excel file I am using for my project in the following link sample_raw_data
Here is some code that can be used to reproduce the DataFrame that is read in from excel:
excel = pd.DataFrame({
'CLAIM': {0: 7538, 1: 7538, 2: 540, 3: 540, 4: 4605, 5: 1740, 6: 7605},
'CODE1': {0: 359, 1: 359, 2: 428, 3: 428, 4: 1670, 5: 134, 6: 415},
'AGE': {0: 71, 1: 71, 2: 73, 3: 73, 4: 40, 5: 55, 6: 56},
'DATE': {0: 43797, 1: 43797, 2: 43754, 3: 43754, 4: 43803, 5: 43823,
6: 43818}
})