Skip to content

Explicit column dtype specification in read_* functions #1858

Closed
@wesm

Description

@wesm

e.g. columns with values like 01001 are getting converted to int

example from mailing list:

df = read_csv('test_data.csv')
df.head()
     oid   did mode             ox             oy      dx      dy
0  1001  1001   01  272311.659358  176751.822655  272675  176375
1  1001  1001   01  272311.659358  176751.822655  272375  176375
2  1001  1001   01  272311.659358  176751.822655  272125  176675
3  1001  1001   06  272311.659358  176751.822655  272675  177125
4  1001  1001   06  272311.659358  176751.822655  272675  176375

df.oid = df.oid.apply(lambda x: str(x).zfill(5))
df.head()
     oid   did mode             ox             oy      dx      dy
0  01001  1001   01  272311.659358  176751.822655  272675  176375
1  01001  1001   01  272311.659358  176751.822655  272375  176375
2  01001  1001   01  272311.659358  176751.822655  272125  176675
3  01001  1001   06  272311.659358  176751.822655  272675  177125
4  01001  1001   06  272311.659358  176751.822655  272675  176375

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementIO DataIO issues that don't fit into a more specific labelTestingpandas testing functions or related to the test suite

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions