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实现查询苹果手机维修进度
Mar 16 Python
Linux下用Python脚本监控目录变化代码分享
May 21 Python
Django如何配置mysql数据库
May 04 Python
Python采集代理ip并判断是否可用和定时更新的方法
May 07 Python
python操作redis方法总结
Jun 06 Python
python脚本实现验证码识别
Jun 07 Python
使用python Fabric动态修改远程机器hosts的方法
Oct 26 Python
python使用Qt界面以及逻辑实现方法
Jul 10 Python
Python完全识别验证码自动登录实例详解
Nov 24 Python
django2.2 和 PyMySQL版本兼容问题
Feb 17 Python
PyQt5实现登录页面
May 30 Python
Python学习之包与模块详解
Mar 19 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
DOTA2游戏同人动画《龙之血》导演接受采访
2021/03/05 欧美动漫
火车头采集器3.0采集图文教程
2007/03/17 PHP
laravel容器延迟加载以及auth扩展详解
2015/03/02 PHP
浅谈PHP实现大流量下抢购方案
2017/12/15 PHP
Thinkphp 框架扩展之行为扩展原理与实现方法分析
2020/04/23 PHP
PHP SESSION跨页面传递失败解决方案
2020/12/11 PHP
JavaScript Cookie的读取和写入函数
2009/12/08 Javascript
js采用map取到id集合组并且实现点击一行选中一行
2013/12/16 Javascript
什么是MEAN?JavaScript编程中的MEAN是什么意思?
2014/12/18 Javascript
javascript基于DOM实现省市级联下拉框的方法
2015/05/14 Javascript
如何动态加载外部Javascript文件
2015/12/02 Javascript
jquery通过name属性取值的简单实现方法
2016/06/20 Javascript
在Web项目中引入Jquery插件报错的完美解决方案(图解)
2016/09/19 Javascript
微信小程序 开发工具快捷键整理
2016/10/31 Javascript
JavaScript实现的原生态兼容IE6可调可控滚动文字功能详解
2017/09/19 Javascript
详解使用PM2管理nodejs进程
2017/10/24 NodeJs
详解react-redux插件入门
2018/04/19 Javascript
vue动态循环出的多个select出现过的变为disabled(实例代码)
2019/11/10 Javascript
vue 使用外部JS与调用原生API操作示例
2019/12/02 Javascript
深入理解Antd-Select组件的用法
2020/02/25 Javascript
python在windows下实现备份程序实例
2014/07/04 Python
Python中列表(list)操作方法汇总
2014/08/18 Python
详解Python多线程
2016/11/14 Python
Python爬虫框架Scrapy基本用法入门教程
2018/07/26 Python
Python面向对象程序设计类变量与成员变量、类方法与成员方法用法分析
2019/04/12 Python
Pytorch Tensor的索引与切片例子
2019/08/18 Python
Python爬虫之urllib基础用法教程
2019/10/12 Python
Python PyQt5整理介绍
2020/04/01 Python
详解pandas获取Dataframe元素值的几种方法
2020/06/14 Python
白兰氏健康Mall:BRAND’S
2017/11/13 全球购物
Zadig&Voltaire官网:法国时装品牌
2018/01/05 全球购物
新闻专业学生的自我评价
2014/02/13 职场文书
工程建设实施方案
2014/03/14 职场文书
4s店销售经理岗位职责
2014/07/19 职场文书
幼儿园家长安全责任书
2014/07/22 职场文书
Java 实战项目之家居购物商城系统详解流程
2021/11/11 Java/Android