Skip to content

Commit a17429b

Browse files
committed
DOC: update and share NDFrame.to_csv() docstring
1 parent 191d2ab commit a17429b

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

pandas/core/generic.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9266,13 +9266,15 @@ def to_csv(self, path_or_buf=None, sep=",", na_rep='', float_format=None,
92669266
quotechar='"', line_terminator='\n', chunksize=None,
92679267
tupleize_cols=None, date_format=None, doublequote=True,
92689268
escapechar=None, decimal='.'):
9269-
r"""Write DataFrame to a comma-separated values (csv) file
9269+
r"""Write object to a comma-separated values (csv) file
92709270
92719271
Parameters
92729272
----------
92739273
path_or_buf : string or file handle, default None
92749274
File path or object, if None is provided the result is returned as
92759275
a string.
9276+
.. versionchanged:: 0.24.0
9277+
Was previously named "path" for Series.
92769278
sep : character, default ','
92779279
Field delimiter for the output file.
92789280
na_rep : string, default ''
@@ -9289,7 +9291,7 @@ def to_csv(self, path_or_buf=None, sep=",", na_rep='', float_format=None,
92899291
index_label : string or sequence, or False, default None
92909292
Column label for index column(s) if desired. If None is given, and
92919293
`header` and `index` are True, then the index names are used. A
9292-
sequence should be given if the DataFrame uses MultiIndex. If
9294+
sequence should be given if the object uses MultiIndex. If
92939295
False do not print fields for index names. Use index_label=False
92949296
for easier importing in R
92959297
mode : str
@@ -9330,6 +9332,8 @@ def to_csv(self, path_or_buf=None, sep=",", na_rep='', float_format=None,
93309332
Character recognized as decimal separator. E.g. use ',' for
93319333
European data
93329334
9335+
.. versionchanged:: 0.24.0
9336+
The order of arguments for Series was changed.
93339337
"""
93349338

93359339
df = self if isinstance(self, ABCDataFrame) else self.to_frame()

pandas/core/series.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3764,10 +3764,9 @@ def from_csv(cls, path, sep=',', parse_dates=True, header=None,
37643764
return result
37653765

37663766
def to_csv(self, *args, **kwargs):
3767-
"""
3768-
See DataFrame.to_csv()
3769-
# TODO
3770-
"""
3767+
# This entire method is going to be removed, so the shared docstring
3768+
# mechanism is overkill
3769+
__doc__ = NDFrame.to_csv.__doc__
37713770

37723771
names = ['path_or_buf', 'sep', 'na_rep', 'float_format', 'columns',
37733772
'header', 'index', 'index_label', 'mode', 'encoding',

0 commit comments

Comments
 (0)