Explicilty convert categorical columns as category datatypes

PHOTO EMBED

Sun Sep 18 2022 12:39:41 GMT+0000 (Coordinated Universal Time)

Saved by @hquizzagan #python

df['Categorical_Column'] = df['Categorical_Column'].astype('category')
content_copyCOPY

Usually, columns containing strings or objects are either categorical variables, or just normal string data. If categorical, it is better to rewrite their datatype as `category` as they use less memory and operations will be much faster.