QST: Pandas read_excel parsing in wrong format

This issue has been created since 2022-11-18.

Research

  • I have searched the [pandas] tag on StackOverflow for similar questions.

  • I have asked my usage related question on StackOverflow.

Link to question on StackOverflow

https://stackoverflow.com/questions/63067926/how-to-stop-python-auto-date-parsing-while-reading-a-excel-file

Question about pandas

I was facing an issue for some dates in my xlsx file separated by dashes
image

after doing reading the excel,
pandas converts this dates to ISO format but also interchanges month and day in the format

e.g. for 09-11-2018 (MM-DD-YYYY), ISO format should look like 2018-09-11T00:00:00.000Z but panda converts it into 2018-11-09T00:00:00.000Z which is wrong since 11 is not a month
but nothing happens for the dates in the form MM/DD/YYYY

Debugger output after doing:

claim = pd.read_excel(
    file_name,
    engine='openpyxl',
    sheet_name='claim',
)

image

why is this happening and how can i resolve this isssue?

I tried to do stop the parsing by using all the suggestions given in the StackOverflow question but none of them worked in my case as well as that question's author's case

MarcoGorelli wrote this answer on 2022-11-18

Hi @pathikg - could you make your example reproducible please?

vamsi-verma-s wrote this answer on 2022-11-18

Hi @pathikg can you check if excel is converting the strings as dates by checking the data type of the cell in excel.

since you are using openpyxl you may also want to just try reading the sheet using openpyxl itself, that way it will be easier to figure out if pandas converts the strings later or not.

MarcoGorelli wrote this answer on 2022-11-25

closing for now, but can reopen if you address #49770 (comment)

More Details About Repo
Owner Name pandas-dev
Repo Name pandas
Full Name pandas-dev/pandas
Language Python
Created Date 2010-08-24
Updated Date 2022-12-07
Star Count 36164
Watcher Count 1118
Fork Count 15472
Issue Count 3683

YOU MAY BE INTERESTED

Issue Title Created Date Comment Count Updated Date
Doesn't play on Vivaldi 0 2021-10-20 2022-10-14
Low framerate on Firefox 88 8 2021-10-15 2022-10-06
No. of Objects parameter needed 0 2022-02-14 2022-11-13
Will this bot be detected by Pinksale anti-bot system? 2 2022-01-20 2022-10-04
error:The request failed: Google returned a response with code 429. 2 2021-09-16 2022-11-27
NaN in f'{word}_monthly 0 2021-08-11 2022-11-27
Use `$INCLUDE` in zone file 0 2022-09-27 2022-10-31
Minimum optimal weight 3 2022-07-07 2022-11-30
QA for https://github.com/microsoft/workshop-library/tree/main/intro-notebooks 1 2022-02-08 2022-09-29
Create and use service account 2 2021-07-14 2022-11-06
fix the sleep_time variable 1 2021-11-26 2022-10-09
No session id in rpc context if it's sent over http 3 2022-06-16 2022-11-18
errors with assertions in subaccounts 2 2021-01-04 2022-11-13
Move more packages into `dom` 20 2021-09-03 2022-12-05
This application failed to start because it could not find or load the Qt platform plugin "windows". 2 2022-11-17 2022-12-05
带大写字母的锚链接点开会有bug无法正常跳转到滚动条,可以先把相关引用链接后面的锚名称都改为小写 1 2021-12-26 2022-11-14
删除数据字典中的一条数据后重新添加该字典编码,提示“字典编码已存在!”,而且报表参数中还能继续使用已被删除的字典编码 1 2022-04-11 2022-12-04
Needs to be 'root' to run? 0 2021-01-21 2022-07-05
telemetry: addr: not work in config file. (0.16.0) 1 2021-12-01 2022-11-01
Support develop-branches / releases of 3rd-party modules 4 2019-09-30 2022-11-22
Romanian mobile phone number regex 1 2021-08-31 2022-11-27
How to specify type with metadata of pubsub? 2 2022-08-31 2022-12-03
register_block_pattern() --> PostTypes restriction NOT working 1 2022-09-13 2022-10-06
Visual Theme Building Tracking Issue 10 2022-03-03 2022-12-06
`stub` is applied to source AND target 2 2021-12-09 2022-11-25
Better separates high level components and low level components 0 2021-10-27 2022-12-04
Bootstrap 5 ToastHeader: charCode warning 0 2021-10-15 2022-09-20
Cannot receive subscription event from DataStore.observe with owner auth rule setting 18 2021-10-02 2022-12-04
New maintainer 0 2021-06-25 2022-01-14
Msi installer not support auto-update 1 2022-07-06 2022-12-06
GameCenter Plugin award_achievement not displaying banner 4 2021-06-03 2022-11-28
Documentation Doesn't explain how to consume a consumable in app purchase 5 2021-07-01 2022-11-28
Support StoreKit `request_review` 0 2021-06-05 2022-11-28
升级/安装 1.5.x 用户的一些注意事项 0 2021-08-27 2022-11-18
[Remoto] Mobile Flutter Developer na Compasso UOL 0 2021-08-11 2022-05-14
add a fallback for vuepress default search 2 2021-07-23 2022-11-22
Wrong Value after Update to v10.4.2 3 2022-03-14 2022-11-20
RStudio does not detect TeX installation 52 2019-03-06 2022-09-14
Parse report error message bug 1 2021-03-12 2022-09-26
[Android] Animated Stickers doesn't work 28 2020-07-02 2022-12-06
Switching from a streaming service with linked Account to service with stream key leaves account linked 3 2021-09-02 2022-11-22
Kibana -Xpack - add new filter - feature 1 2022-09-22 2022-10-10
solov2 c++推理和python推理不一致 8 2022-06-06 2022-12-03
[BUG] testMatch doesnt load tests from several folders 0 2022-06-05 2022-10-06
How do I get the public name of the hotspot from the hotspot address? 1 2022-01-07 2022-11-18
OpenPGP signature issues 4 2021-10-19 2022-10-06
Round progress bar in Course Outline block 0 2022-02-02 2022-07-15
👑 [需求]组件bar不支持自定义shape 1 2021-11-12 2022-07-20
Copy of the config for migration 0 2022-03-30 2022-12-04
Identify framework post-submit iOS tests which catch `dart` regressions 8 2022-05-10 2022-11-23