Reputation: 4624
How to prevent pandas.read_csv()
from inferring the data types. For example, its converting strings true
and false
to Bool: True
and False
. The columns are many for many files, therefore not feasible to do:
df['field_name'] = df['field_name'].astype(np.float64)
for each of the columns in each file. I prefer pandas to just read file as it is, no type inferring.
Upvotes: 13
Views: 7874
Reputation: 32125
Use the parameter dtype=object
for Pandas to keep the data as such at load time.
Upvotes: 21