to_sql.html)
    * [ pandas.read_gbq ](pandas.read_gbq.html)
    * [ pandas.read_stata ](pandas.read_stata.html)
    * [ pandas.DataFrame.to_stata ](pandas.DataFrame.to_stata.html)
    * [ pandas.io.stata.StataReader.data_label ](pandas.io.stata.StataReader.data_label.html)
    * [ pandas.io.stata.StataReader.value_labels ](pandas.io.stata.StataReader.value_labels.html)
    * [ pandas.io.stata.StataReader.variable_labels ](pandas.io.stata.StataReader.variable_labels.html)
    * [ pandas.io.stata.StataWriter.write_file ](pandas.io.stata.StataWriter.write_file.html)
  * [ General functions ](../general_functions.html)
  * [ Series ](../series.html)
  * [ DataFrame ](../frame.html)
  * [ pandas arrays, scalars, and data types ](../arrays.html)
  * [ Index objects ](../indexing.html)
  * [ Date offsets ](../offset_frequency.html)
  * [ Window ](../window.html)
  * [ GroupBy ](../groupby.html)
  * [ Resampling ](../resampling.html)
  * [ Style ](../style.html)
  * [ Plotting ](../plotting.html)
  * [ Options and settings ](../options.html)
  * [ Extensions ](../extensions.html)
  * [ Testing ](../testing.html)
  * [ Missing values ](../missing_value.html)

  * [ __ ](../../index.html)
  * [ API reference ](../index.html)
  * [ Input/output ](../io.html)
  * pandas.DataF... 

#  pandas.DataFrame.to_csv  #

DataFrame.  to_csv  (  _ path_or_buf  =  None  _ , _ *  _ , _ sep  =  ','  _ ,
_ na_rep  =  ''  _ , _ float_format  =  None  _ , _ columns  =  None  _ , _
header  =  True  _ , _ index  =  True  _ , _ index_label  =  None  _ , _ mode
=  'w'  _ , _ encoding  =  None  _ , _ compression  =  'infer'  _ , _ quoting
=  None  _ , _ quotechar  =  '"'  _ , _ lineterminator  =  None  _ , _
chunksize  =  None  _ , _ date_format  =  None  _ , _ doublequote  =  True  _
, _ escapechar  =  None  _ , _ decimal  =  '.'  _ , _ errors  =  'strict'  _ ,
_ storage_options  =  None  _ )  [ [source]  ](https://github.com/pandas-
dev/pandas/blob/v2.2.2/pandas/core/generic.py#L3797-L3984) #

    

Write object to a comma-separated values (csv) file.

Parameters  :

    

**path_or_buf** str, path object, file-like object, or None, default None

    

String, path object (implementing os.PathLike[str]), or file-like object
implementing a write() function. If None, the result is returned as a string.
If a non-binary file object is passed, it should be opened with
newline=ââ  , disabling universal newlines. If a binary file object is
passed,  mode  might need to contain a  âbâ  .

**sep** str, default â,â

    

String of length 1. Field delimiter for the output file.

**na_rep** str, default ââ

    

Missing data representation.

**float_format** str, Callable, default None

    

Format string for floating point numbers. If a Callable is given, it takes
precedence over other numeric formatting parameters, like decimal.

**columns** sequence, optional

    

Columns to write.

**header** bool or list of str, default True

    

Write out the column names. If a list of strings is given it is assumed to be
aliases for the column names.

**index** bool, default True

    

Write row names (index).

**index_label** str 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 object uses MultiIndex. If False do not print fields for index
names. Use index_label=False for easier importing in R.

**mode** {âwâ, âxâ, âaâ}, default âwâ

    

Forwarded to either  open(mode=)  or  fsspec.open(mode=)  to control the file
opening. Typical values include:

  * âwâ, truncate the file first. 

  * âxâ, exclusive creation, failing if the file already exists. 

  * âaâ, append to the end of file if it exists. 

**encoding** str, optional

    

A string representing the encoding to use in the output file, defaults to
âutf-8â.  encoding  is not supported if  path_or_buf  is a non-bin