Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

to_csv / to_pickle optionally use fast gzip compressionlevel=1 #33196

Closed
kernc opened this issue Apr 1, 2020 · 1 comment · Fixed by #33398
Closed

to_csv / to_pickle optionally use fast gzip compressionlevel=1 #33196

kernc opened this issue Apr 1, 2020 · 1 comment · Fixed by #33398
Assignees
Labels
IO Data IO issues that don't fit into a more specific label
Milestone

Comments

@kernc
Copy link
Contributor

kernc commented Apr 1, 2020

Code Sample, a copy-pastable example if possible

Enhancement proposal

>>> df.to_csv('data.csv.gz')  # Awfully slow

>>> df.to_pickle('data.pkl.bz2')  # Awfully slow

>>> df.to_csv('data.csv.gz', fast=True)  # Uses fast compressionlevel=1

# or, better:

>>> pd.options.io.compressionlevel = 1

>>> df.to_pickle('data.pkl.bz2')  # Uses fast compressionlevel=1

...

Problem description

Compression of large objects in pandas is slow.

Popular evidence comparing compression levels for average payloads shows [1] [2] that compressed size is usually far less variable than compression time, which most often spans several folds.
compressionlevel=1 is orders of magnitude faster, whereas compressionlevel=9 is only 10% smaller.

One optimizes for size, the other for speed, and much fewer people ever need something in between.

Expected Output

Output of pd.show_versions()

1.1.0.dev0+786.gec7734169

@jessefarnham
Copy link
Contributor

take

@jreback jreback added the IO Data IO issues that don't fit into a more specific label label Apr 8, 2020
@jreback jreback added this to the 1.1 milestone Apr 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
IO Data IO issues that don't fit into a more specific label
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants