Last active
January 10, 2024 17:31
-
-
Save mh0w/96d69fe3e873396875432540397b495a to your computer and use it in GitHub Desktop.
check object size
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
""" | |
sys: | |
Return the size of an object in bytes.The object can be any type of object. | |
All built-in objects will return correct results, but this does not have to | |
hold true for third-party extensions as it is implementation specific. | |
pandas/polars: | |
Returns the size of an object in KB/MB/GB. Checking the dtypes will be | |
informative (e.g., float64 likely to use more space than int8). | |
""" | |
import sys | |
s = "abcdef" | |
sys.getsizeof(s) #55 | |
# Pandas | |
my_df.info(verbose=False, memory_usage="deep") | |
my_df.dtypes | |
# Polars | |
my_df.estimated_size() | |
my_df.dtypes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment