pd.read_excel parses rows as int if containing only numbers, even when marked as text or indicated string with e.g. '02 #12186
Labels
Dtype Conversions
Unexpected or buggy dtype conversions
Duplicate Report
Duplicate issue or pull request
IO Excel
read_excel, to_excel
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
The text was updated successfully, but these errors were encountered: