xxxxxxxxxx
# Change to other data type
df['col'].astype('int')
# Change to categorical data
df["col"].astype('category')
# Change date
import datetime as dt
df['date_column'] = pd.to_datetime(df['datetime_column']).dt.date
xxxxxxxxxx
# convert all columns of DataFrame
df = df.apply(pd.to_numeric) # convert all columns of DataFrame
# convert just columns "a" and "b"
df[["a", "b"]] = df[["a", "b"]].apply(pd.to_numeric)
xxxxxxxxxx
dfn = df.convert_dtypes()
>>> dfn
a b c d e f
0 1 x True h 10 <NA>
1 2 y False i <NA> 100.5
2 3 z <NA> <NA> 20 200.0