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 相关文章推荐
linux环境下安装pyramid和新建项目的步骤
Nov 27 Python
python回调函数的使用方法
Jan 23 Python
python3.3使用tkinter开发猜数字游戏示例
Mar 14 Python
Python的Tornado框架异步编程入门实例
Apr 24 Python
python中随机函数random用法实例
Apr 30 Python
python、java等哪一门编程语言适合人工智能?
Nov 13 Python
名片管理系统python版
Jan 11 Python
简单了解Django ContentType内置组件
Jul 23 Python
解决python 文本过滤和清理问题
Aug 28 Python
PyQt5+Caffe+Opencv搭建人脸识别登录界面
Aug 28 Python
解决paramiko执行命令超时的问题
Apr 16 Python
python 实时调取摄像头的示例代码
Nov 25 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
Syphon 虹吸式咖啡壶冲煮–拨动法
2021/03/03 冲泡冲煮
PHP 中的一些经验积累
2006/10/09 PHP
如何把PHP转成EXE文件
2006/10/09 PHP
PHP模板引擎Smarty的缓存使用总结
2014/04/24 PHP
PHP中浮点数计算比较及取整不准确的解决方法
2015/01/09 PHP
php删除一个路径下的所有文件夹和文件的方法
2018/02/07 PHP
PHP中检查isset()和!empty()函数的必要性
2019/02/13 PHP
laravel框架select2多选插件初始化默认选中项操作示例
2020/02/18 PHP
javascript静态页面传值的三种方法分享
2013/11/12 Javascript
js获取json元素数量的方法
2015/01/27 Javascript
js通过iframe加载外部网页的实现代码
2015/04/05 Javascript
javascript实现日期按月份加减
2015/05/15 Javascript
JavaScript事件学习小结(五)js中事件类型之鼠标事件
2016/06/09 Javascript
简单的渐变轮播插件
2017/01/12 Javascript
vue.js单文件组件中非父子组件的传值实例
2018/09/13 Javascript
js比较两个单独的数组或对象是否相等的实例代码
2019/04/28 Javascript
用node.js写一个jenkins发版脚本
2019/05/21 Javascript
Node.js之删除文件夹(含递归删除)代码实例
2019/09/09 Javascript
js HTML DOM EventListener功能与用法实例分析
2020/04/27 Javascript
原生JavaScript实现弹幕组件的示例代码
2020/10/12 Javascript
js中实现继承的五种方法
2021/01/25 Javascript
[01:56]《DOTA2》中文配音CG
2013/04/22 DOTA
Python编程中的异常处理教程
2015/08/21 Python
matplotlib基础绘图命令之errorbar的使用
2020/08/13 Python
如何使用PyCharm引入需要使用的包的方法
2020/09/22 Python
开办大学饮食联盟创业计划书
2014/01/29 职场文书
创业计划书的写作技巧及要点
2014/01/31 职场文书
2014年冬季防火方案
2014/05/21 职场文书
初一新生军训方案
2014/05/22 职场文书
2014年语文教研组工作总结
2014/12/06 职场文书
新郎父亲婚礼致辞
2015/07/27 职场文书
MySQL中datetime时间字段的四舍五入操作
2021/10/05 MySQL
图片批量处理 - 尺寸、格式、水印等
2022/03/07 杂记
一条 SQL 语句执行过程
2022/03/17 MySQL
使用Python通过企业微信应用给企业成员发消息
2022/04/18 Python
苹果macOS 13开发者预览版Beta 8发布 正式版10月发布
2022/09/23 数码科技