pandas.DataFrame.to_csv
2017-06-08 11:36
441 查看
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=None, quoting=None, quotechar=’”’, line_terminator=’\n’, chunksize=None, tupleize_cols=False, date_format=None, doublequote=True, escapechar=None, decimal=’.’)[source]
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. 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 columns : 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 indexare 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 mode : str Python write mode, default ‘w’ encoding : string, 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 : string, optional a string representing the compression to use in the output file, allowed values are ‘gzip’, ‘bz2’, ‘xz’, only used when the first argument is a filename line_terminator : string, default '\n' The newline character or character sequence to use in the output file 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 : string (length 1), default ‘”’ character used to quote fields doublequote : boolean, default True Control quoting of quotechar inside a field escapechar : string (length 1), default None character used to escape sep and quotechar when appropriate chunksize : int or None rows to write at a time tupleize_cols : boolean, default False write multi_index columns as a list of tuples (if True) or new (expanded format) if False) date_format : string, default None Format string for datetime objects decimal: string, default ‘.’ Character recognized as decimal separator. E.g. use ‘,’ for European data New in version 0.16.0. |
---|
to_csv精度设置
df_data.to_csv(outfile, index=False,header=False, float_format='%.3f')
相关文章推荐
- pandas.DataFrame.to_csv
- From Pandas to Apache Spark’s Dataframe
- pandas.DataFrame.to_json按行转json的方法
- Python pandas读取csv文件直接转化成二维列表(Dataframe转化为list)
- python远程连接mysql以及pandas.DataFrame.to_sql写入数据库
- pandas dataFrame to_excel 报错[ UnicodeDecodeError: 'ascii' codec can't decode byte 0xe7 in position 7
- dataframe save to CSV file, 中文问题
- pandas.DataFrame.to_json按行转json
- 【跟着stackoverflow学Pandas】--Converting a Pandas GroupBy object to DataFrame-Groupby对象转换为DataFrame
- dataframe 内的to_csv和from_csv能使存储的数据不变
- pyspark-csv To DataFrame
- python pandas dataframe to_sql方法error及其解决
- 【跟着stackoverflow学Pandas】How to iterate over rows in a DataFrame in Pandas-DataFrame按行迭代
- 2017.07.04回顾 dataframe组合 groupby sort to_csv不存index
- 【跟着stackoverflow学Pandas】 - Adding new column to existing DataFrame in Python pandas - Pandas 添加列
- Python Pandas批量读取csv文件到dataframe的方法
- pandas Dataframe filter
- pandas的to_csv()使用方法
- pandas-1:Series && DataFrame
- python-pandas-Series和DataFrame的基本功能