python的pandas工具包,保存.csv文件时不要表头。
2017-11-22 10:28
1831 查看
用pandas处理.csv文件时,有时我们希望保存的.csv文件没有表头,于是我去看了DataFrame.to_csv的document。发现只需要再添加header=None这个参数就行了(默认是True),下面贴上document:
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=None, date_format=None, doublequote=True, escapechar=None, decimal='.') Write DataFrame to a comma-separated values (csv) file
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< 4000 /span> 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 the column names. If a list of strings 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 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 Deprecated since version 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. 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). date_format : string, default None Format string for datetime objects decimal: string, default ‘.’ Character recognized as decimal separator. E.g. use ‘,’ for European data
相关文章推荐
- python的pandas工具包,保存.csv文件时不要表头的实例
- python用pandas工具包来处理.csv文件,包括读写和切片。
- 使用python的pandas库读取csv文件保存至mysql数据库
- Python使用pandas & pymysql读取MySQL数据到csv文件中
- Python利用pandas计算多个CSV文件数据值的实例
- Python学习笔记 --- pandas将excel转化为csv文件
- python 下载csv文件保存到 redis
- 使用pandas将numpy中的数组数据保存到csv文件
- 25 pandas的使用,转成numpy数组以及将list数组保存成csv格式的文件
- python 利用pandas将arff文件转csv文件
- Python3使用csv模块csv.writer().writerow()保存csv文件,产生空行的问题
- [python]pandas的read_csv读入csv文件报错 'utf-8' codec can't decode byte 0xbe in position 0
- Python Pandas批量读取csv文件到dataframe的方法
- 使用pandas将numpy中的数组数据保存到csv文件的方法
- Python使用pandas处理CSV文件的实例讲解
- Python3使用csv模块csv.writer().writerow()保存csv文件,产生空行的问题
- Python 随机生成100行1000列的0~5之间的数据,并保存到csv文件
- 几行Python代码生成饭店营业额模拟数据并保存为CSV文件
- Python3使用csv模块csv.writer().writerow()保存csv文件,产生空行的问题
- python:pandas合并csv文件的方法(图书数据集成)