Skip to content

Instantly share code, notes, and snippets.

@anair123
Created May 29, 2022 14:26
# convert data types
df['age'] = df['age'].astype('int8')
df['weight'] = df['weight'].astype('int8')
df['income'] = df['income'].astype('int32')
df['height'] = df['height'].astype('float16')
memory_after = df.memory_usage().sum()
print(f'Memory usage: {memory_after} bytes')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment