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实现命令行版的火车票查看器
Aug 05 Python
Python机器学习之决策树算法
Dec 22 Python
详解Django的model查询操作与查询性能优化
Oct 16 Python
使用Python实现企业微信的自动打卡功能
Apr 30 Python
18个Python脚本可加速你的编码速度(提示和技巧)
Oct 17 Python
numpy创建单位矩阵和对角矩阵的实例
Nov 29 Python
解决pycharm同一目录下无法import其他文件
Feb 12 Python
TensorBoard 计算图的查看方式
Feb 15 Python
Jupyter打开图形界面并画出正弦函数图像实例
Apr 24 Python
Python 实现 T00ls 自动签到脚本代码(邮件+钉钉通知)
Jul 06 Python
通过Python实现Payload分离免杀过程详解
Jul 13 Python
python接入支付宝的实例操作
Jul 20 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中计算字符串相似度的函数代码
2012/12/29 PHP
php获取汉字首字母的函数
2013/11/07 PHP
php计算当前程序执行时间示例
2014/04/24 PHP
浅谈php正则表达式中的非贪婪模式匹配的使用
2014/11/25 PHP
深入理解PHP变量的值类型和引用类型
2015/10/21 PHP
PHP实现基本留言板功能原理与步骤详解
2020/03/26 PHP
js不是基础的基础
2006/12/24 Javascript
SeaJS入门教程系列之完整示例(三)
2014/03/03 Javascript
javascript中声明函数的方法及调用函数的返回值
2014/07/22 Javascript
javascript实现2016新年版日历
2016/01/25 Javascript
轻松掌握JavaScript装饰者模式
2016/08/27 Javascript
使用BootStrapValidator完成前端输入验证
2016/09/28 Javascript
jQuery图片切换动画特效
2016/11/02 Javascript
微信小程序 wx.login解密出现乱码的问题解决办法
2017/03/10 Javascript
JavaScript实现树的遍历算法示例【广度优先与深度优先】
2017/10/26 Javascript
jQuery实现导航样式布局操作示例【可自定义样式布局】
2018/07/24 jQuery
详解Vue源码学习之双向绑定
2019/04/10 Javascript
详解JavaScript中的强制类型转换
2019/04/15 Javascript
Vue之beforeEach非登录不能访问的实现(代码亲测)
2019/07/18 Javascript
Element Carousel 走马灯的具体实现
2020/07/26 Javascript
javascript实现京东登录显示隐藏密码
2020/08/02 Javascript
[02:41]2015国际邀请赛中国区预选赛观战指南
2015/05/20 DOTA
python搭建简易服务器分析与实现
2012/12/15 Python
Python中使用glob和rmtree删除目录子目录及所有文件的例子
2014/11/21 Python
Python的Django框架中的数据库配置指南
2015/07/17 Python
python绘制中国大陆人口热力图
2018/11/07 Python
python实现一个猜拳游戏
2020/04/05 Python
在Keras中实现保存和加载权重及模型结构
2020/06/15 Python
音乐专业自荐信
2014/02/07 职场文书
校园安全广播稿
2014/02/08 职场文书
小学生期末评语
2014/04/21 职场文书
考博专家推荐信
2014/05/10 职场文书
银行柜员求职自荐书
2014/06/18 职场文书
小学一年级数学教学计划
2015/01/20 职场文书
幼儿园老师工作总结2015
2015/05/22 职场文书
ConditionalOnProperty配置swagger不生效问题及解决
2022/06/14 Java/Android