-
-
Notifications
You must be signed in to change notification settings - Fork 18k
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
Default to_* methods to compression='infer' #22011
Changes from 38 commits
8689167
3ccfb00
648bf4d
be724fa
9fe27c9
65f0689
868e671
c3b76ee
cebc0d9
8411eb2
c098c8f
2f6601d
eb7f9b5
d4a5c90
abd19e3
2f670fe
aa9ce13
a6aabad
8a0c97e
6be808d
63e6591
fadb943
0edffc7
97f5de5
83bc0a8
874a4bf
14c3945
9a4dc41
25bdb4c
1ba8f3a
24e051e
387d1d2
12f14e2
6db23d9
e3a0f56
af8c137
f8829a6
918c0f8
eadf68e
cf5b62e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1715,7 +1715,7 @@ def to_panel(self): | |
|
||
def to_csv(self, path_or_buf=None, sep=",", na_rep='', float_format=None, | ||
columns=None, header=True, index=True, index_label=None, | ||
mode='w', encoding=None, compression=None, quoting=None, | ||
mode='w', encoding=None, compression='infer', quoting=None, | ||
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 add versionchanged in each of the modified doc-strings 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. Done in 1ba8f3a |
||
quotechar='"', line_terminator='\n', chunksize=None, | ||
tupleize_cols=None, date_format=None, doublequote=True, | ||
escapechar=None, decimal='.'): | ||
|
@@ -1750,10 +1750,14 @@ def to_csv(self, path_or_buf=None, sep=",", na_rep='', float_format=None, | |
encoding : string, optional | ||
A string representing the encoding to use in the output file, | ||
defaults to 'ascii' on Python 2 and 'utf-8' on Python 3. | ||
compression : {'infer', 'gzip', 'bz2', 'zip', 'xz', None}, default None | ||
compression : {'infer', 'gzip', 'bz2', 'zip', 'xz', None}, | ||
default 'infer' | ||
If 'infer' and `path_or_buf` is path-like, then detect compression | ||
from the following extensions: '.gz', '.bz2', '.zip' or '.xz' | ||
(otherwise no compression). | ||
.. versionchanged:: 0.24.0 | ||
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. I think you need to have a blank after this or it has a warning, @TomAugspurger @datapythonista ? 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. Done in f8829a6, but would be good to hear from @TomAugspurger and @datapythonista, since we have complex situations such as: DOCLINE
DOCLINE
.. versionchanged:: 0.23.0
here is what was added
.. versionchanged:: 0.24.0 here is what changed
DOCLINE For example, is the above OKAY or do we need additional blanks? 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. @dhimmel I think you need the additional blank lines (before, and not sure if after). The reason is not that much an standard in this case, but about sphinx understanding the directive. What we expect in the documentation, is that it's rendered like in the But if you don't leave the right blank lines, sphinx doesn't detect it's a directive, and the text is rendered as it is. See this case: https://pandas.pydata.org/pandas-docs/version/0.23.1/generated/pandas.IntervalIndex.from_tuples.html So, the best is if you can build the documentation, and check that it's rendered all right. This can be done by Let me know if you have any issue. 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. Updated in eadf68e and built the docs locally to confirm they're rendering properly. Turns out the blank line before is required. After is not required. In between multiple statements is not required. |
||
'infer' option added and set to default | ||
|
||
line_terminator : string, default ``'\n'`` | ||
The newline character or character sequence to use in the output | ||
file | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1933,7 +1933,7 @@ def _repr_latex_(self): | |
|
||
def to_json(self, path_or_buf=None, orient=None, date_format=None, | ||
double_precision=10, force_ascii=True, date_unit='ms', | ||
default_handler=None, lines=False, compression=None, | ||
default_handler=None, lines=False, compression='infer', | ||
index=True): | ||
""" | ||
Convert the object to a JSON string. | ||
|
@@ -2000,11 +2000,14 @@ def to_json(self, path_or_buf=None, orient=None, date_format=None, | |
|
||
.. versionadded:: 0.19.0 | ||
|
||
compression : {'infer', 'gzip', 'bz2', 'zip', 'xz', None}, default None | ||
compression : {'infer', 'gzip', 'bz2', 'zip', 'xz', None}, | ||
default 'infer' | ||
A string representing the compression to use in the output file, | ||
only used when the first argument is a filename. | ||
|
||
.. versionadded:: 0.21.0 | ||
.. versionchanged:: 0.24.0 | ||
'infer' option added and set to default | ||
|
||
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. e.g. like this is good |
||
index : boolean, default True | ||
Whether to include the index values in the JSON string. Not | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3767,7 +3767,7 @@ def from_csv(cls, path, sep=',', parse_dates=True, header=None, | |
|
||
def to_csv(self, path=None, index=True, sep=",", na_rep='', | ||
float_format=None, header=False, index_label=None, | ||
mode='w', encoding=None, compression=None, date_format=None, | ||
mode='w', encoding=None, compression='infer', date_format=None, | ||
decimal='.'): | ||
""" | ||
Write Series to a comma-separated values (csv) file | ||
|
@@ -3795,10 +3795,13 @@ def to_csv(self, path=None, index=True, sep=",", na_rep='', | |
encoding : string, optional | ||
a string representing the encoding to use if the contents are | ||
non-ascii, for python versions prior to 3 | ||
compression : string, optional | ||
compression : None or string, default 'infer' | ||
A string representing the compression to use in the output file. | ||
Allowed values are 'gzip', 'bz2', 'zip', 'xz'. This input is only | ||
used when the first argument is a filename. | ||
Allowed values are None, 'gzip', 'bz2', 'zip', 'xz', and 'infer'. | ||
This input is only used when the first argument is a filename. | ||
.. versionchanged:: 0.24.0 | ||
'infer' option added and set to default | ||
|
||
date_format: string, default None | ||
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. same |
||
Format string for datetime objects. | ||
decimal: string, default '.' | ||
|
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -28,7 +28,7 @@ | |||
# interface to/from | ||||
def to_json(path_or_buf, obj, orient=None, date_format='epoch', | ||||
double_precision=10, force_ascii=True, date_unit='ms', | ||||
default_handler=None, lines=False, compression=None, | ||||
default_handler=None, lines=False, compression='infer', | ||||
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. Not sure where to update the to_json docs... didn't see a docstring in this function. 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. Line 1905 in 322dbf4
|
||||
index=True): | ||||
|
||||
if not index and orient not in ['split', 'table']: | ||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add a tiny bit more detail that this means to infer based on the file extension.
any updates needed in io.rst?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 1ba8f3a
I looked through https://pandas.pydata.org/pandas-docs/version/0.23.3/io.html and only saw the need for one small update (a
versionchanged
note) added in 24e051e.