Skip to content

Read_csv should raise error on bad dtypes #3795

@hayd

Description

@hayd

OPs code from http://stackoverflow.com/questions/16988526/pandas-reading-csv-as-string-type

Add: auto conversion from a passed str or np.string_ to np.object might be ok

df
           A         B
1A  0.209059  0.275554
1B  0.742666  0.721165

df.to_csv(savefile)

df_read = pd.read_csv(savefile, dtype=str, index_col=0)
   A  B
B  (  <

Actually I get something different on dev:

In [101]: pd.read_csv('a', index_col=0, dtype=str)
Out[101]:
 A B


Metadata

Metadata

Assignees

No one assigned

    Labels

    Dtype ConversionsUnexpected or buggy dtype conversionsEnhancementIO DataIO issues that don't fit into a more specific label

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions