Skip to content

Commit 7c5e18d

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

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

pandas/core/generic.py

+6-2
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

+4-5
Original file line numberDiff line numberDiff line change
@@ -3764,11 +3764,6 @@ 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-
"""
3771-
37723767
names = ['path_or_buf', 'sep', 'na_rep', 'float_format', 'columns',
37733768
'header', 'index', 'index_label', 'mode', 'encoding',
37743769
'compression', 'quoting', 'quotechar', 'line_terminator',
@@ -3817,6 +3812,10 @@ def to_csv(self, *args, **kwargs):
38173812

38183813
return self.to_frame().to_csv(**kwargs)
38193814

3815+
# This entire method is going to be removed, so the shared docstring
3816+
# mechanism is overkill
3817+
to_csv.__doc__ = generic.NDFrame.to_csv.__doc__
3818+
38203819
@Appender(generic._shared_docs['to_excel'] % _shared_doc_kwargs)
38213820
def to_excel(self, excel_writer, sheet_name='Sheet1', na_rep='',
38223821
float_format=None, columns=None, header=True, index=True,

0 commit comments

Comments
 (0)