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

Closed
@dickreuter

Description

@dickreuter

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Dtype ConversionsUnexpected or buggy dtype conversionsDuplicate ReportDuplicate issue or pull requestIO Excelread_excel, to_excel

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions