Skip to content

Commit

Permalink
DOC: update and share NDFrame.to_csv() docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
toobaz committed Jul 25, 2018
1 parent 191d2ab commit 7c5e18d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
8 changes: 6 additions & 2 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -9266,13 +9266,15 @@ def to_csv(self, path_or_buf=None, sep=",", na_rep='', float_format=None,
quotechar='"', line_terminator='\n', chunksize=None,
tupleize_cols=None, date_format=None, doublequote=True,
escapechar=None, decimal='.'):
r"""Write DataFrame to a comma-separated values (csv) file
r"""Write object to a comma-separated values (csv) file
Parameters
----------
path_or_buf : string or file handle, default None
File path or object, if None is provided the result is returned as
a string.
.. versionchanged:: 0.24.0
Was previously named "path" for Series.
sep : character, default ','
Field delimiter for the output file.
na_rep : string, default ''
Expand All @@ -9289,7 +9291,7 @@ def to_csv(self, path_or_buf=None, sep=",", na_rep='', float_format=None,
index_label : string or sequence, or False, default None
Column label for index column(s) if desired. If None is given, and
`header` and `index` are True, then the index names are used. A
sequence should be given if the DataFrame uses MultiIndex. If
sequence should be given if the object uses MultiIndex. If
False do not print fields for index names. Use index_label=False
for easier importing in R
mode : str
Expand Down Expand Up @@ -9330,6 +9332,8 @@ def to_csv(self, path_or_buf=None, sep=",", na_rep='', float_format=None,
Character recognized as decimal separator. E.g. use ',' for
European data
.. versionchanged:: 0.24.0
The order of arguments for Series was changed.
"""

df = self if isinstance(self, ABCDataFrame) else self.to_frame()
Expand Down
9 changes: 4 additions & 5 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -3764,11 +3764,6 @@ def from_csv(cls, path, sep=',', parse_dates=True, header=None,
return result

def to_csv(self, *args, **kwargs):
"""
See DataFrame.to_csv()
# TODO
"""

names = ['path_or_buf', 'sep', 'na_rep', 'float_format', 'columns',
'header', 'index', 'index_label', 'mode', 'encoding',
'compression', 'quoting', 'quotechar', 'line_terminator',
Expand Down Expand Up @@ -3817,6 +3812,10 @@ def to_csv(self, *args, **kwargs):

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

# This entire method is going to be removed, so the shared docstring
# mechanism is overkill
to_csv.__doc__ = generic.NDFrame.to_csv.__doc__

@Appender(generic._shared_docs['to_excel'] % _shared_doc_kwargs)
def to_excel(self, excel_writer, sheet_name='Sheet1', na_rep='',
float_format=None, columns=None, header=True, index=True,
Expand Down

0 comments on commit 7c5e18d

Please sign in to comment.