Created
September 17, 2022 23:31
-
-
Save petrosDemetrakopoulos/8567099778ac47f45e2d45174cfe10df to your computer and use it in GitHub Desktop.
Pandas categorical column as object
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import random | |
colors = ['WHITE', 'BLACK','RED','YELLOW','BLUE','GREEN'] | |
colors_column = [random.choice(colors) for x in range(1000)] | |
df = pd.DataFrame({'color':colors_column}) | |
print(df.info(memory_usage="deep")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment