def to_csv(self, 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='"', line_terminator=None, chunksize=None, tupleize_cols=None, date_format=None, doublequote=True, escapechar=None, decimal='.'):
    '\n        Write object to a comma-separated values (csv) file.\n\n        .. versionchanged:: 0.24.0\n            The order of arguments for Series was changed.\n\n        Parameters\n        ----------\n        path_or_buf : str or file handle, default None\n            File path or object, if None is provided the result is returned as\n            a string.\n\n            .. versionchanged:: 0.24.0\n\n               Was previously named "path" for Series.\n\n        sep : str, default \',\'\n            String of length 1. Field delimiter for the output file.\n        na_rep : str, default \'\'\n            Missing data representation.\n        float_format : str, default None\n            Format string for floating point numbers.\n        columns : sequence, optional\n            Columns to write.\n        header : bool or list of str, default True\n            Write out the column names. If a list of strings is given it is\n            assumed to be aliases for the column names.\n\n            .. versionchanged:: 0.24.0\n\n               Previously defaulted to False for Series.\n\n        index : bool, default True\n            Write row names (index).\n        index_label : str or sequence, or False, default None\n            Column label for index column(s) if desired. If None is given, and\n            `header` and `index` are True, then the index names are used. A\n            sequence should be given if the object uses MultiIndex. If\n            False do not print fields for index names. Use index_label=False\n            for easier importing in R.\n        mode : str\n            Python write mode, default \'w\'.\n        encoding : str, optional\n            A string representing the encoding to use in the output file,\n            defaults to \'ascii\' on Python 2 and \'utf-8\' on Python 3.\n        compression : str, default \'infer\'\n            Compression mode among the following possible values: {\'infer\',\n            \'gzip\', \'bz2\', \'zip\', \'xz\', None}. If \'infer\' and `path_or_buf`\n            is path-like, then detect compression from the following\n            extensions: \'.gz\', \'.bz2\', \'.zip\' or \'.xz\'. (otherwise no\n            compression).\n\n            .. versionchanged:: 0.24.0\n\n               \'infer\' option added and set to default.\n\n        quoting : optional constant from csv module\n            Defaults to csv.QUOTE_MINIMAL. If you have set a `float_format`\n            then floats are converted to strings and thus csv.QUOTE_NONNUMERIC\n            will treat them as non-numeric.\n        quotechar : str, default \'\\"\'\n            String of length 1. Character used to quote fields.\n        line_terminator : str, optional\n            The newline character or character sequence to use in the output\n            file. Defaults to `os.linesep`, which depends on the OS in which\n            this method is called (\'\\n\' for linux, \'\\r\\n\' for Windows, i.e.).\n\n            .. versionchanged:: 0.24.0\n        chunksize : int or None\n            Rows to write at a time.\n        tupleize_cols : bool, default False\n            Write MultiIndex columns as a list of tuples (if True) or in\n            the new, expanded format, where each MultiIndex column is a row\n            in the CSV (if False).\n\n            .. deprecated:: 0.21.0\n               This argument will be removed and will always write each row\n               of the multi-index as a separate row in the CSV file.\n        date_format : str, default None\n            Format string for datetime objects.\n        doublequote : bool, default True\n            Control quoting of `quotechar` inside a field.\n        escapechar : str, default None\n            String of length 1. Character used to escape `sep` and `quotechar`\n            when appropriate.\n        decimal : str, default \'.\'\n            Character recognized as decimal separator. E.g. use \',\' for\n            European data.\n\n        Returns\n        -------\n        None or str\n            If path_or_buf is None, returns the resulting csv format as a\n            string. Otherwise returns None.\n\n        See Also\n        --------\n        read_csv : Load a CSV file into a DataFrame.\n        to_excel : Load an Excel file into a DataFrame.\n\n        Examples\n        --------\n        >>> df = pd.DataFrame({\'name\': [\'Raphael\', \'Donatello\'],\n        ...                    \'mask\': [\'red\', \'purple\'],\n        ...                    \'weapon\': [\'sai\', \'bo staff\']})\n        >>> df.to_csv(index=False)\n        \'name,mask,weapon\\nRaphael,red,sai\\nDonatello,purple,bo staff\\n\'\n        '
    df = (self if isinstance(self, ABCDataFrame) else self.to_frame())
    if (tupleize_cols is not None):
        warnings.warn("The 'tupleize_cols' parameter is deprecated and will be removed in a future version", FutureWarning, stacklevel=2)
    else:
        tupleize_cols = False
    from pandas.io.formats.csvs import CSVFormatter
    formatter = CSVFormatter(df, path_or_buf, line_terminator=line_terminator, sep=sep, encoding=encoding, compression=compression, quoting=quoting, na_rep=na_rep, float_format=float_format, cols=columns, header=header, index=index, index_label=index_label, mode=mode, chunksize=chunksize, quotechar=quotechar, tupleize_cols=tupleize_cols, date_format=date_format, doublequote=doublequote, escapechar=escapechar, decimal=decimal)
    formatter.save()
    if (path_or_buf is None):
        return formatter.path_or_buf.getvalue()
Write object to a comma-separated values (csv) file.

.. versionchanged:: 0.24.0
    The order of arguments for Series was changed.

Parameters
----------
path_or_buf : str 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 : str, default ','
    String of length 1. Field delimiter for the output file.
na_rep : str, default ''
    Missing data representation.
float_format : str, default None
    Format string for floating point numbers.
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.

    .. versionchanged:: 0.24.0

       Previously defaulted to False for Series.

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 : str
    Python write mode, default 'w'.
encoding : str, optional
    A string representing the encoding to use in the output file,
    defaults to 'ascii' on Python 2 and 'utf-8' on Python 3.
compression : str, default 'infer'
    Compression mode among the following possible values: {'infer',
    'gzip', 'bz2', 'zip', 'xz', None}. If 'infer' and `path_or_buf`
    is path-like, then detect compression from the following
    extensions: '.gz', '.bz2', '.zip' or '.xz'. (otherwise no
    compression).

    .. versionchanged:: 0.24.0

       'infer' option added and set to default.

quoting : optional constant from csv module
    Defaults to csv.QUOTE_MINIMAL. If you have set a `float_format`
    then floats are converted to strings and thus csv.QUOTE_NONNUMERIC
    will treat them as non-numeric.
quotechar : str, default '\"'
    String of length 1. Character used to quote fields.
line_terminator : str, optional
    The newline character or character sequence to use in the output
    file. Defaults to `os.linesep`, which depends on the OS in which
    this method is called ('\n' for linux, '\r\n' for Windows, i.e.).

    .. versionchanged:: 0.24.0
chunksize : int or None
    Rows to write at a time.
tupleize_cols : bool, default False
    Write MultiIndex columns as a list of tuples (if True) or in
    the new, expanded format, where each MultiIndex column is a row
    in the CSV (if False).

    .. deprecated:: 0.21.0
       This argument will be removed and will always write each row
       of the multi-index as a separate row in the CSV file.
date_format : str, default None
    Format string for datetime objects.
doublequote : bool, default True
    Control quoting of `quotechar` inside a field.
escapechar : str, default None
    String of length 1. Character used to escape `sep` and `quotechar`
    when appropriate.
decimal : str, default '.'
    Character recognized as decimal separator. E.g. use ',' for
    European data.

Returns
-------
None or str
    If path_or_buf is None, returns the resulting csv format as a
    string. Otherwise returns None.

See Also
--------
read_csv : Load a CSV file into a DataFrame.
to_excel : Load an Excel file into a DataFrame.

Examples
--------
>>> df = pd.DataFrame({'name': ['Raphael', 'Donatello'],
...                    'mask': ['red', 'purple'],
...                    'weapon': ['sai', 'bo staff']})
>>> df.to_csv(index=False)
'name,mask,weapon\nRaphael,red,sai\nDonatello,purple,bo staff\n'
def to_csv(self, 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='"', line_terminator=None, chunksize=None, tupleize_cols=None, date_format=None, doublequote=True, escapechar=None, decimal='.'):
    '\n        Write object to a comma-separated values (csv) file.\n\n        .. versionchanged:: 0.24.0\n            The order of arguments for Series was changed.\n\n        Parameters\n        ----------\n        path_or_buf : str or file handle, default None\n            File path or object, if None is provided the result is returned as\n            a string.\n\n            .. versionchanged:: 0.24.0\n\n               Was previously named "path" for Series.\n\n        sep : str, default \',\'\n            String of length 1. Field delimiter for the output file.\n        na_rep : str, default \'\'\n            Missing data representation.\n        float_format : str, default None\n            Format string for floating point numbers.\n        columns : sequence, optional\n            Columns to write.\n        header : bool or list of str, default True\n            Write out the column names. If a list of strings is given it is\n            assumed to be aliases for the column names.\n\n            .. versionchanged:: 0.24.0\n\n               Previously defaulted to False for Series.\n\n        index : bool, default True\n            Write row names (index).\n        index_label : str or sequence, or False, default None\n            Column label for index column(s) if desired. If None is given, and\n            `header` and `index` are True, then the index names are used. A\n            sequence should be given if the object uses MultiIndex. If\n            False do not print fields for index names. Use index_label=False\n            for easier importing in R.\n        mode : str\n            Python write mode, default \'w\'.\n        encoding : str, optional\n            A string representing the encoding to use in the output file,\n            defaults to \'ascii\' on Python 2 and \'utf-8\' on Python 3.\n        compression : str, default \'infer\'\n            Compression mode among the following possible values: {\'infer\',\n            \'gzip\', \'bz2\', \'zip\', \'xz\', None}. If \'infer\' and `path_or_buf`\n            is path-like, then detect compression from the following\n            extensions: \'.gz\', \'.bz2\', \'.zip\' or \'.xz\'. (otherwise no\n            compression).\n\n            .. versionchanged:: 0.24.0\n\n               \'infer\' option added and set to default.\n\n        quoting : optional constant from csv module\n            Defaults to csv.QUOTE_MINIMAL. If you have set a `float_format`\n            then floats are converted to strings and thus csv.QUOTE_NONNUMERIC\n            will treat them as non-numeric.\n        quotechar : str, default \'\\"\'\n            String of length 1. Character used to quote fields.\n        line_terminator : str, optional\n            The newline character or character sequence to use in the output\n            file. Defaults to `os.linesep`, which depends on the OS in which\n            this method is called (\'\\n\' for linux, \'\\r\\n\' for Windows, i.e.).\n\n            .. versionchanged:: 0.24.0\n        chunksize : int or None\n            Rows to write at a time.\n        tupleize_cols : bool, default False\n            Write MultiIndex columns as a list of tuples (if True) or in\n            the new, expanded format, where each MultiIndex column is a row\n            in the CSV (if False).\n\n            .. deprecated:: 0.21.0\n               This argument will be removed and will always write each row\n               of the multi-index as a separate row in the CSV file.\n        date_format : str, default None\n            Format string for datetime objects.\n        doublequote : bool, default True\n            Control quoting of `quotechar` inside a field.\n        escapechar : str, default None\n            String of length 1. Character used to escape `sep` and `quotechar`\n            when appropriate.\n        decimal : str, default \'.\'\n            Character recognized as decimal separator. E.g. use \',\' for\n            European data.\n\n        Returns\n        -------\n        None or str\n            If path_or_buf is None, returns the resulting csv format as a\n            string. Otherwise returns None.\n\n        See Also\n        --------\n        read_csv : Load a CSV file into a DataFrame.\n        to_excel : Load an Excel file into a DataFrame.\n\n        Examples\n        --------\n        >>> df = pd.DataFrame({\'name\': [\'Raphael\', \'Donatello\'],\n        ...                    \'mask\': [\'red\', \'purple\'],\n        ...                    \'weapon\': [\'sai\', \'bo staff\']})\n        >>> df.to_csv(index=False)\n        \'name,mask,weapon\\nRaphael,red,sai\\nDonatello,purple,bo staff\\n\'\n        '
    df = (self if isinstance(self, ABCDataFrame) else self.to_frame())
    if (tupleize_cols is not None):
        warnings.warn("The 'tupleize_cols' parameter is deprecated and will be removed in a future version", FutureWarning, stacklevel=2)
    else:
        tupleize_cols = False
    from pandas.io.formats.csvs import CSVFormatter
    formatter = CSVFormatter(df, path_or_buf, line_terminator=line_terminator, sep=sep, encoding=encoding, compression=compression, quoting=quoting, na_rep=na_rep, float_format=float_format, cols=columns, header=header, index=index, index_label=index_label, mode=mode, chunksize=chunksize, quotechar=quotechar, tupleize_cols=tupleize_cols, date_format=date_format, doublequote=doublequote, escapechar=escapechar, decimal=decimal)
    formatter.save()
    if (path_or_buf is None):
        return formatter.path_or_buf.getvalue()