for col in col_names:
    df[col] = df[col].astype('category', copy=False)
print("""
Example data changed to category type""")
print(df)
print(df.dtypes)
how to convert all columns from numeric to categorical using Python