@@ -1494,70 +1494,80 @@ def to_csv(self, path_or_buf=None, sep=",", na_rep='', float_format=None,
1494
1494
quotechar = '"' , line_terminator = '\n ' , chunksize = None ,
1495
1495
tupleize_cols = None , date_format = None , doublequote = True ,
1496
1496
escapechar = None , decimal = '.' ):
1497
- r"""Write DataFrame to a comma-separated values (csv) file
1497
+ """Write a DataFrame to a comma-separated values (CSV) file.
1498
+
1499
+ Write a DataFrame to a comma-separated values (CSV) file with an user
1500
+ specified format (e.g. a separator, missing values representation,
1501
+ quoting etc.), header and index specification and possible compression.
1498
1502
1499
1503
Parameters
1500
1504
----------
1501
- path_or_buf : string or file handle, default None
1505
+ path_or_buf : str or file handle, default None
1502
1506
File path or object, if None is provided the result is returned as
1503
1507
a string.
1504
- sep : character , default ','
1508
+ sep : str (length 1) , default ','
1505
1509
Field delimiter for the output file.
1506
- na_rep : string , default ''
1507
- Missing data representation
1508
- float_format : string , default None
1509
- Format string for floating point numbers
1510
+ na_rep : str , default ''
1511
+ Missing data representation.
1512
+ float_format : str , default None
1513
+ Format string for floating point numbers.
1510
1514
columns : sequence, optional
1511
- Columns to write
1512
- header : boolean or list of string , default True
1515
+ Columns to write.
1516
+ header : bool or list of str , default True
1513
1517
Write out the column names. If a list of strings is given it is
1514
- assumed to be aliases for the column names
1515
- index : boolean , default True
1516
- Write row names (index)
1517
- index_label : string or sequence, or False, default None
1518
+ assumed to be aliases for the column names.
1519
+ index : bool , default True
1520
+ Write row names (index).
1521
+ index_label : str or sequence, or False, default None
1518
1522
Column label for index column(s) if desired. If None is given, and
1519
- `header` and `index` are True, then the index names are used. A
1520
- sequence should be given if the DataFrame uses MultiIndex. If
1521
- False do not print fields for index names. Use index_label=False
1522
- for easier importing in R
1523
- mode : str
1524
- Python write mode, default 'w'
1525
- encoding : string , optional
1523
+ `header` and `index` are ` True` , then the index names are used. A
1524
+ sequence should be given if the DataFrame uses MultiIndex. If
1525
+ ` False` do not print fields for index names.
1526
+ Use `index_label=False` for easier importing in R.
1527
+ mode : str, default 'w'
1528
+ Python write mode.
1529
+ encoding : str , optional
1526
1530
A string representing the encoding to use in the output file,
1527
1531
defaults to 'ascii' on Python 2 and 'utf-8' on Python 3.
1528
- compression : string , optional
1529
- a string representing the compression to use in the output file,
1530
- allowed values are 'gzip', 'bz2', 'xz',
1531
- only used when the first argument is a filename
1532
- line_terminator : string , default ``'\n'``
1532
+ compression : str , optional
1533
+ A string representing the compression to use in the output file,
1534
+ allowed values are 'gzip', 'bz2', 'xz', only used when the first
1535
+ argument is a filename.
1536
+ line_terminator : str , default ``'\n '``
1533
1537
The newline character or character sequence to use in the output
1534
1538
file
1535
1539
quoting : optional constant from csv module
1536
1540
defaults to csv.QUOTE_MINIMAL. If you have set a `float_format`
1537
1541
then floats are converted to strings and thus csv.QUOTE_NONNUMERIC
1538
1542
will treat them as non-numeric
1539
- quotechar : string (length 1), default '\"'
1543
+ quotechar : str (length 1), default '\" '
1540
1544
character used to quote fields
1541
- doublequote : boolean , default True
1545
+ doublequote : bool , default True
1542
1546
Control quoting of `quotechar` inside a field
1543
- escapechar : string (length 1), default None
1547
+ escapechar : str (length 1), default None
1544
1548
character used to escape `sep` and `quotechar` when appropriate
1545
1549
chunksize : int or None
1546
1550
rows to write at a time
1547
- tupleize_cols : boolean , default False
1551
+ tupleize_cols : bool , default False
1548
1552
.. deprecated:: 0.21.0
1549
1553
This argument will be removed and will always write each row
1550
1554
of the multi-index as a separate row in the CSV file.
1551
1555
1552
- Write MultiIndex columns as a list of tuples (if True) or in
1556
+ Write MultiIndex columns as a list of tuples (if ` True` ) or in
1553
1557
the new, expanded format, where each MultiIndex column is a row
1554
- in the CSV (if False).
1555
- date_format : string , default None
1558
+ in the CSV (if ` False` ).
1559
+ date_format : str , default None
1556
1560
Format string for datetime objects
1557
- decimal: string , default '.'
1561
+ decimal: str , default '.'
1558
1562
Character recognized as decimal separator. E.g. use ',' for
1559
1563
European data
1560
1564
1565
+ See Also
1566
+ --------
1567
+ pandas.Series.to_csv : Write a Series to a comma-separated values (CSV)
1568
+ file.
1569
+ pandas.read_csv : Read a comma-separated values (CSV) file into
1570
+ a DataFrame.
1561
1571
"""
1562
1572
1563
1573
if tupleize_cols is not None :
0 commit comments