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.2.tar.gz
(7.5 kB
view hashes)
Built Distribution
Close
Hashes for pd_helper-0.1.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92e58d4544274679627655cb3082d5e1d1df553c4a872de8e511d577628ac356 |
|
MD5 | 3a1768cde872179338cc20df5ba94c39 |
|
BLAKE2b-256 | 4eea841fe50ec6de7e5037215a2f4fedc84f5ed9bf84fc64834e7aa9a1f96064 |