pandas.DataFrame.to_csv¶
- DataFrame.to_csv(path_or_buf, sep=', ', na_rep='', float_format=None, cols=None, header=True, index=True, index_label=None, mode='w', nanRep=None, encoding=None, quoting=None, line_terminator='n', chunksize=None, **kwds)¶
Write DataFrame to a comma-separated values (csv) file
- path_or_buf : string or file handle / StringIO
- File path
- sep : character, default ”,”
- Field delimiter for the output file.
- na_rep : string, default ‘’
- Missing data representation
- float_format : string, default None
- Format string for floating point numbers
- cols : sequence, optional
- Columns to write
- header : boolean or list of string, default True
- Write out column names. If a list of string is given it is assumed to be aliases for the column names
- index : boolean, default True
- Write row names (index)
- 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 False do not print fields for index names. Use index_label=False for easier importing in R
nanRep : deprecated, use na_rep mode : Python write mode, default ‘w’ encoding : string, optional
a string representing the encoding to use if the contents are non-ascii, for python versions prior to 3line_terminator: string, default ‘
- ‘
- The newline character or character sequence to use in the output file
- quoting : optional constant from csv module
- defaults to csv.QUOTE_MINIMAL
chunksize : rows to write at a time