A helpful script to optimize a Pandas DataFrame.
Project description
pd-helper
A helpful package to streamline Pandas DataFrame optimization.
Save 50-75% on DataFrame memory usage by running the optimizer.
Auto configure dtypes for appropriate data types in each column.
Basic Usage to Iterate over DataFrame
from pd_helper.helper import optimize
if __name__ == "__main__":
# some DataFrame, df
df = optimize(df)
Better Usage With Multiprocessing
from pd_helper.helper import optimize
if __name__ == "__main__":
# some DataFrame, df
df = optimize(df, enable_mp=True)
Specify Special Mappings
from pd_helper.helper import optimize
if __name__ == "__main__":
# some DataFrame, df
special_mappings = {'string': ['col_1', 'col_2'],
'category': ['col_3', 'col_4']}
# special mappings will be applied instead of by optimize ruleset, they will be returned.
df = optimize(df
, enable_mp=True,
special_mappings=special_mappings
)
Install
pip install pd-helper
Sample Results
Starting with 175.63 MB memory.
After optmization.
Ending with 65.33 MB memory.
TODO
-
Improve efficiency of iterating on DataFrame.
-
Allow user to toggle logging.
-
Provide tools for imputing missing data.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pd_helper-0.1.3.tar.gz
(7.5 kB
view hashes)
Built Distribution
Close
Hashes for pd_helper-0.1.3-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c9441fe4c770b42cc14bb1b440b26a22bfc3bf15c34a5cd59c71e147ee284724 |
|
MD5 | 1dc6bf0eb55ed36a10312b1c3e147c6c |
|
BLAKE2b-256 | 03013758c24ac8d511477291042236e0f691ea665090a1c33e83f9aba349c60e |