-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
ENH: Allow compression in NDFrame.to_csv to be a dict with optional arguments (#26023) #26024
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
4e73dc4
ENH/BUG: Add arcname to to_csv for ZIP compressed csv filename (#26023)
drew-heenan ab7620d
DOC: Updated docs for arcname in NDFrame.to_csv (#26023)
drew-heenan 2e782f9
conform to line length limit
drew-heenan 83e8834
Fixed test_to_csv_zip_arcname for Windows paths
drew-heenan d238878
Merge remote-tracking branch 'upstream/master' into issue-26023
drew-heenan b41be54
to_csv compression may now be dict with possible keys 'method' and 'a…
drew-heenan 60ea58c
test_to_csv_compression_dict uses compression_only fixture
drew-heenan 8ba9082
delegate dict handling to _get_compression_method, type annotations
drew-heenan 0a3a9fd
fix import order, None type annotations
drew-heenan a1cb3f7
compression args passed as kwargs, update relevant docs
drew-heenan af2a96c
style/doc improvements, change arcname to archive_name
drew-heenan 5853a28
Merge branch 'master' into issue-26023
drew-heenan 789751f
Merge branch 'master' into issue-26023
drew-heenan 5b09e6f
add to_csv example, no method test, Optional types, tweaks; update wh…
drew-heenan 68a2b4d
remove Index import type ignore
drew-heenan c856f50
Revert "remove Index import type ignore"
drew-heenan 8df6c81
Merge remote-tracking branch 'upstream/master' into issue-26023
drew-heenan 40d0252
Merge branch 'master' into issue-26023
drew-heenan 18a735d
Improve docs/examples
drew-heenan 103c877
Merge branch 'master' into issue-26023
drew-heenan b6c34bc
Merge remote-tracking branch 'upstream/master' into issue-26023
WillAyd 969d387
Added back missed Callable import in generic
WillAyd abfbc0f
Merge remote-tracking branch 'upstream/master' into issue-26023
WillAyd 04ae25d
Address comments
WillAyd 9c22652
Typing cleanup
WillAyd 56a75c2
Cleaned up docstring
WillAyd bbfea34
Merge remote-tracking branch 'upstream/master' into issue-26023
WillAyd 7717f16
Merge remote-tracking branch 'upstream/master' into issue-26023
WillAyd 779511e
blackify
WillAyd 780eb04
Merge remote-tracking branch 'upstream/master' into issue-26023
WillAyd 6c4e679
Added annotations where feasible
WillAyd 1b567c9
Black and lint
WillAyd 9324b63
Merge remote-tracking branch 'upstream/master' into issue-26023
WillAyd 7cf65ee
isort fixup
WillAyd 29374f3
Docstring fixup and more annotations
WillAyd 6701aa4
Merge remote-tracking branch 'upstream/master' into issue-26023
WillAyd 0f5489d
lint fixup
WillAyd e04138e
mypy fixup
WillAyd 6f2bf00
whatsnew fixup
WillAyd 865aa81
Annotation and doc fixups
WillAyd 8d1deee
mypy typeshed bug fix
WillAyd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Improve docs/examples
- Loading branch information
commit 18a735dbf16a62c802cfd6afad4fcd1c9857c91d
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2970,13 +2970,14 @@ def to_csv(self, path_or_buf=None, sep=",", na_rep='', float_format=None, | |
detect compression mode from the following extensions: '.gz', | ||
'.bz2', '.zip' or '.xz'. (otherwise no compression). If dict given | ||
and mode is 'zip' or inferred as 'zip', other entries passed as | ||
kwargs to ByteZipFile. | ||
additional compression options. | ||
|
||
.. versionchanged:: 0.25.0 | ||
|
||
May now be a dict with key 'method' as compression mode | ||
and other entries as ByteZipFile kwargs if compression mode | ||
is 'zip' | ||
and other entries as additional compression options if | ||
compression mode is 'zip'. | ||
|
||
quoting : optional constant from csv module | ||
Defaults to csv.QUOTE_MINIMAL. If you have set a `float_format` | ||
then floats are converted to strings and thus csv.QUOTE_NONNUMERIC | ||
|
@@ -3028,10 +3029,10 @@ def to_csv(self, path_or_buf=None, sep=",", na_rep='', float_format=None, | |
... 'weapon': ['sai', 'bo staff']}) | ||
>>> df.to_csv(index=False) | ||
'name,mask,weapon\nRaphael,red,sai\nDonatello,purple,bo staff\n' | ||
|
||
# create 'out.zip' containing 'out.csv' | ||
>>> compression_opts = dict(method='zip', archive_name='out.csv') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you put the comment before the example (and put a blank line between cases); also might need to have a DOCTEST: SKIP here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you do this |
||
>>> df.to_csv('out.zip', index=False, compression=compression_opts) | ||
|
||
# creates 'out.zip' containing 'out.csv' | ||
""" | ||
|
||
df = self if isinstance(self, ABCDataFrame) else self.to_frame() | ||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.