Command
df.astypeExplanation
df.astype() is used to change the datatype of columns.
Examples
Convert column to integer
df["col"] = df["col"].astype(int)Convert multiple columns at once
df = df.astype({"col1": float, "col2": "string"})df.astypedf.astype() is used to change the datatype of columns.
Convert column to integer
df["col"] = df["col"].astype(int)Convert multiple columns at once
df = df.astype({"col1": float, "col2": "string"})