Skip to content

pd.read_excel parses rows as int if containing only numbers, even when marked as text or indicated string with e.g. '02 #12186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dickreuter opened this issue Jan 30, 2016 · 1 comment
Labels
Dtype Conversions Unexpected or buggy dtype conversions Duplicate Report Duplicate issue or pull request IO Excel read_excel, to_excel

Comments

@dickreuter
Copy link
Contributor

When loading an excel file with pandas that contains a row with integers that have preceding zeros such as 01, the number is automatically parsed as integer and results as 1. This even happens when the row is formatted as 'text' or the number is entered as '02 (second row). I believe it would be correct if the row was parsed as string in that case.

df=pd.read_excel(r'c:\temp\string.xlsx','Sheet1')
df['row1'][0]
df['row1'][1]
1
2
instead of
01
02

example excel file:
https://www.dropbox.com/s/k7coyy8gnntl1hv/string.xlsx?dl=0

The issue was discussed here:
http://stackoverflow.com/questions/35084022/load-xlsx-into-pandas-as-string?noredirect=1#comment57890144_35084022

@jreback jreback added Dtype Conversions Unexpected or buggy dtype conversions IO Excel read_excel, to_excel Duplicate Report Duplicate issue or pull request labels Jan 30, 2016
@jreback
Copy link
Contributor

jreback commented Jan 30, 2016

dupe of #8212

pull-requests to fix are accepted!

@jreback jreback closed this as completed Jan 30, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dtype Conversions Unexpected or buggy dtype conversions Duplicate Report Duplicate issue or pull request IO Excel read_excel, to_excel
Projects
None yet
Development

No branches or pull requests

2 participants