python的pandas工具包,保存.csv文件时不要表头的实例

 更新时间:2018年06月14日 15:34:13   作者:xiaotao_1  
今天小编小编就为大家分享一篇python的pandas工具包,保存.csv文件时不要表头的实例,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧

用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 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文件时不要表头的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。

相关文章

  • pycharm配置pyqt5-tools开发环境的方法步骤

    pycharm配置pyqt5-tools开发环境的方法步骤

    这篇文章主要介绍了pycharm配置pyqt5-tools开发环境的方法步骤,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
    2019-02-02
  • Django1.7+python 2.78+pycharm配置mysql数据库

    Django1.7+python 2.78+pycharm配置mysql数据库

    这篇文章主要介绍了Django1.7+python 2.78+pycharm配置mysql数据库的相关资料,需要的朋友可以参考下
    2016-10-10
  • Requests库实现数据抓取与处理功能

    Requests库实现数据抓取与处理功能

    本文介绍了Python中常用的第三方库Requests的基本用法和高级功能,我们学习了如何发起HTTP请求、处理响应、使用会话对象、设置代理和证书验证等技巧,需要的朋友可以参考下
    2023-05-05
  • Python本地及虚拟解释器配置过程解析

    Python本地及虚拟解释器配置过程解析

    这篇文章主要介绍了Python本地及虚拟解释器配置过程解析,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
    2020-10-10
  • python执行系统命令后获取返回值的几种方式集合

    python执行系统命令后获取返回值的几种方式集合

    今天小编就为大家分享一篇python执行系统命令后获取返回值的几种方式集合,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
    2018-05-05
  • Tensorflow中的placeholder和feed_dict的使用

    Tensorflow中的placeholder和feed_dict的使用

    这篇文章主要介绍了Tensorflow中的placeholder和feed_dict的使用,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
    2018-07-07
  • 基于Python和Tkinter实现高考倒计时功能

    基于Python和Tkinter实现高考倒计时功能

    随着高考的临近,每个考生都在紧锣密鼓地复习,这时候,一款实用的倒计时软件能有效帮助你规划剩余时间,提醒你不要浪费每一分每一秒,今天,我们来聊聊一款基于Python和Tkinter开发的高考倒计时软件,功能简单却极具实用性,让你在紧张的备考过程中不再迷失
    2025-03-03
  • Python3.9安装gmpy2的步骤

    Python3.9安装gmpy2的步骤

    gmpy2是一个Python扩展模块,是对GMP的封装,它的前身是gmpy,接下来通过本文给大家讲解Python3.9安装gmpy2的步骤,安装gmpy2之前需要提前安装python3环境,安装python请自行百度搜索,不同的python版本会对应的gmpy库也是不同的,需要的朋友可以参考下
    2023-05-05
  • 将matplotlib绘图嵌入pyqt的方法示例

    将matplotlib绘图嵌入pyqt的方法示例

    这篇文章主要介绍了将matplotlib绘图嵌入pyqt的方法示例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2020-01-01
  • Python 根据数据模板创建shapefile的实现

    Python 根据数据模板创建shapefile的实现

    今天小编就为大家分享一篇Python 根据数据模板创建shapefile的实现,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
    2019-11-11

最新评论