python - Change column type in pandas - Stack Overflow

PHOTO EMBED

Wed Dec 22 2021 01:55:51 GMT+0000 (Coordinated Universal Time)

Saved by [deleted user]

# 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)
content_copyCOPY

https://stackoverflow.com/questions/15891038/change-column-type-in-pandas