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


Posted in Python onJune 14, 2018

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

Python 相关文章推荐
Python 基础知识之字符串处理
Jan 06 Python
Python编程使用NLTK进行自然语言处理详解
Nov 16 Python
用Python删除本地目录下某一时间点之前创建的所有文件的实例
Dec 14 Python
Python解析命令行读取参数--argparse模块使用方法
Jan 23 Python
python实现公司年会抽奖程序
Jan 22 Python
Djang的model创建的字段和参数详解
Jul 27 Python
python实现屏保程序(适用于背单词)
Jul 30 Python
python线程安全及多进程多线程实现方法详解
Sep 27 Python
python 画3维轨迹图并进行比较的实例
Dec 06 Python
Tensorflow实现在训练好的模型上进行测试
Jan 20 Python
浅谈python print(xx, flush = True) 全网最清晰的解释
Feb 21 Python
Python如何执行精确的浮点数运算
Jul 31 Python
使用python将大量数据导出到Excel中的小技巧分享
Jun 14 #Python
使用pandas将numpy中的数组数据保存到csv文件的方法
Jun 14 #Python
利用pandas将numpy数组导出生成excel的实例
Jun 14 #Python
详解Django 中是否使用时区的区别
Jun 14 #Python
python dataframe 输出结果整行显示的方法
Jun 14 #Python
Python3.6基于正则实现的计算器示例【无优化简单注释版】
Jun 14 #Python
Python3.6简单反射操作示例
Jun 14 #Python
You might like
PHP转换文件夹下所有文件编码的实现代码
2013/06/06 PHP
PHP、Nginx、Apache中禁止网页被iframe引用的方法
2020/10/01 PHP
与jquery serializeArray()一起使用的函数,主要来方便提交表单
2011/01/31 Javascript
非常棒的10款jQuery 幻灯片插件
2011/06/14 Javascript
基于jquery的当鼠标滚轮到最底端继续加载新数据思路分享(多用于微博、空间、论坛 )
2011/10/10 Javascript
javascript淡入淡出效果的实现思路
2012/03/31 Javascript
jQuery实现点击标题输入详细信息
2013/04/16 Javascript
js 浏览本地文件夹系统示例代码
2013/10/24 Javascript
详解javascript的变量与标识符
2016/01/04 Javascript
javascript输出AscII码扩展集中的字符方法
2016/12/26 Javascript
Vue2.0 给Tab标签页和页面切换过渡添加样式的方法
2018/03/13 Javascript
JS 实现获取验证码 倒计时功能
2018/10/29 Javascript
基于Vue-Cli 打包自动生成/抽离相关配置文件的实现方法
2018/12/09 Javascript
nodejs中request库使用HTTPS代理的方法
2019/04/30 NodeJs
微信小程序基于高德地图查找位置并显示文字
2019/10/30 Javascript
Vue+Element-UI实现上传图片并压缩
2019/11/26 Javascript
vue flex 布局实现div均分自动换行的示例代码
2020/08/05 Javascript
谈谈JavaScript中的函数
2020/09/08 Javascript
[01:01:52]DOTA2-DPC中国联赛定级赛 SAG vs iG BO3第二场 1月9日
2021/03/11 DOTA
python中二维阵列的变换实例
2014/10/09 Python
在Python中使用cookielib和urllib2配合PyQuery抓取网页信息
2015/04/25 Python
Python实现Windows和Linux之间互相传输文件(文件夹)的方法
2017/05/08 Python
Python使用pylab库实现绘制直方图功能示例
2018/06/01 Python
Python OpenCV处理图像之图像像素点操作
2018/07/10 Python
关于 Python opencv 使用中的 ValueError: too many values to unpack
2019/06/28 Python
wxPython实现列表增删改查功能
2019/11/19 Python
Python爬取微信小程序Charles实现过程图解
2020/09/29 Python
爱尔兰电子产品购物网站:Komplett.ie
2018/04/04 全球购物
员工考核管理制度
2014/02/02 职场文书
行政办公室岗位职责
2014/03/18 职场文书
《菜园里》教学反思
2014/04/17 职场文书
2015年建党94周年演讲稿
2015/03/19 职场文书
《揠苗助长》教学反思
2016/02/20 职场文书
SQL Server代理:理解SQL代理错误日志处理方法
2021/06/30 SQL Server
OpenCV 图像梯度的实现方法
2021/07/25 Python
搭建zabbix监控以及邮件报警的超级详细教学
2022/07/15 Servers