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中使用OpenCV进行人脸检测的例子
Apr 18 Python
python实现的一个火车票转让信息采集器
Jul 09 Python
Python压缩和解压缩zip文件
Feb 14 Python
Python简单实现enum功能的方法
Apr 25 Python
Python中的time模块与datetime模块用法总结
Jun 30 Python
Python设计模式之代理模式简单示例
Jan 09 Python
python使用Flask操作mysql实现登录功能
May 14 Python
在Python中给Nan值更改为0的方法
Oct 30 Python
Python的对象传递与Copy函数使用详解
Dec 26 Python
QML实现钟表效果
Jun 02 Python
pytorch  网络参数 weight bias 初始化详解
Jun 24 Python
教你使用一行Python代码玩遍童年的小游戏
Aug 23 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中json_encode处理gbk与gb2312中文乱码问题的解决方法
2014/07/10 PHP
PHP针对常规模板引擎中与CSS/JSON冲突的解决方法
2014/08/19 PHP
php写入数据到CSV文件的方法
2015/03/14 PHP
php格式化电话号码的方法
2015/04/24 PHP
PHP实现linux命令tail -f
2016/02/22 PHP
thinkphp配置文件路径的实现方法
2016/08/30 PHP
PHP有序表查找之插值查找算法示例
2018/02/10 PHP
仿猪八戒网左下角的文字滚动效果
2011/10/28 Javascript
js中indexof的用法详细解析
2013/12/24 Javascript
什么是MEAN?JavaScript编程中的MEAN是什么意思?
2014/12/18 Javascript
jQueryMobile之Helloworld与页面切换的方法
2015/02/04 Javascript
js实现仿百度汽车频道选择汽车图片展示实例
2015/05/06 Javascript
JavaScript实现获得所有兄弟节点的方法
2015/07/23 Javascript
jQuery1.9+中删除了live以后的替代方法
2016/06/17 Javascript
JS封装的三级联动菜单(使用时只需要一行js代码)
2016/10/24 Javascript
从零开始学习Node.js系列教程之设置HTTP头的方法示例
2017/04/13 Javascript
Vue.js 表单控件操作小结
2018/03/29 Javascript
JavaScript剩余操作符Rest Operator详解
2019/07/20 Javascript
如何正确理解vue中的key详解
2019/11/02 Javascript
js中关于Blob对象的介绍与使用
2019/11/29 Javascript
Windows8下安装Python的BeautifulSoup
2015/01/22 Python
解决python2.7用pip安装包时出现错误的问题
2017/01/23 Python
python学习基础之循环import及import过程
2018/04/22 Python
理想高通滤波实现Python opencv示例
2019/01/30 Python
python3实现弹弹球小游戏
2019/11/25 Python
Pandas之缺失数据的实现
2021/01/06 Python
css3强大的动画效果animate使用说明及浏览器兼容介绍
2013/01/09 HTML / CSS
html5实现九宫格抽奖可固定抽中某项奖品
2020/06/15 HTML / CSS
购买正版游戏和游戏激活码:Green Man Gaming
2019/11/06 全球购物
美国家居装饰店:Z Gallerie
2020/12/28 全球购物
公司年会策划方案
2014/05/17 职场文书
交通事故死亡赔偿协议书
2014/12/03 职场文书
2015年食品安全工作总结
2015/05/15 职场文书
商业计划书之服装
2019/09/09 职场文书
Python网络编程之ZeroMQ知识总结
2021/04/25 Python
vue-cil之axios的二次封装与proxy反向代理使用说明
2022/04/07 Vue.js