Following this answer (number 4) I am trying to use df.convert_dtypes()
Pandas version: 0.25.3
Reproducible:
import pandas as pd
import numpy as np
data = {
"int": np.zeros((5, ), dtype=np.int),
"float": np.zeros((5, ), dtype=np.float),
"string": ["a", "b", "c", "ddd", "FFFFF"],
"bool": [True, False, True, True, False]
}
df = pd.DataFrame(data)
print(df)
print(df.dtypes)
output so far:
int float string bool 0 0 0.0 a True 1 0 0.0 b False 2 0 0.0 c True 3 0 0.0 ddd True 4 0 0.0 FFFFF False int int32 float float64 string object bool bool dtype: object
df.convert_dtypes()
print(df.dtypes)
I would expect the trivial types, rather than object
, but getting
AttributeError: 'DataFrame' object has no attribute 'convert_dtypes'
What's the way to do this?