Command
df["col"].astype("category")Explanation
Categorical data saves memory and improves performance for repeated string values.
Examples
Convert column to categorical
df["col"] = df["col"].astype("category")df["col"].astype("category")Categorical data saves memory and improves performance for repeated string values.
Convert column to categorical
df["col"] = df["col"].astype("category")