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冒泡排序算法的实现代码
Nov 21 Python
使用Python中PDB模块中的命令来调试Python代码的教程
Mar 30 Python
Python实现把xml或xsl转换为html格式
Apr 08 Python
python使用matplotlib绘制柱状图教程
Feb 08 Python
python爬取淘宝商品详情页数据
Feb 23 Python
基于Python实现用户管理系统
Feb 26 Python
python中metaclass原理与用法详解
Jun 25 Python
Python合并2个字典成1个新字典的方法(9种)
Dec 19 Python
python with (as)语句实例详解
Feb 04 Python
详解Django中views数据查询使用locals()函数进行优化
Aug 24 Python
python 多线程中join()的作用
Oct 29 Python
python自动获取微信公众号最新文章的实现代码
Jul 15 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实现链结人气统计
2006/10/09 PHP
?生?D片??C字串
2006/12/06 PHP
PHP 替换模板变量实现步骤
2009/08/24 PHP
css配合jquery美化 select
2013/11/29 Javascript
利用js动态添加删除table行的示例代码
2013/12/16 Javascript
简单易用的倒计时js代码
2014/08/04 Javascript
jQuery实现返回顶部功能适合不支持js的浏览器
2014/08/19 Javascript
JavaScript中的索引数组、关联数组和静态数组、动态数组讲解
2014/11/08 Javascript
浅析JavaScript中作用域和作用域链
2016/12/06 Javascript
JavaScript奇技淫巧44招【实用】
2016/12/11 Javascript
原生JavaScrpit中异步请求Ajax实现方法
2017/11/03 Javascript
VUE element-ui 写个复用Table组件的示例代码
2017/11/18 Javascript
mpvue微信小程序多列选择器用法之省份城市选择的实现
2019/03/07 Javascript
微信小程序一周时间表功能实现
2019/10/17 Javascript
jquery绑定事件 bind和on的用法与区别分析
2020/05/22 jQuery
基于进程内通讯的python聊天室实现方法
2015/06/28 Python
详解python实现线程安全的单例模式
2018/03/05 Python
Python操作MySQL数据库的方法
2018/06/20 Python
解决pycharm运行出错,代码正确结果不显示的问题
2018/11/30 Python
详解Python做一个名片管理系统
2019/03/14 Python
全面了解django的缓存机制及使用方法
2019/07/22 Python
python数据爬下来保存的位置
2020/02/17 Python
python安装读取grib库总结(推荐)
2020/06/24 Python
python爬取天气数据的实例详解
2020/11/20 Python
荷兰之家英文站:Holland at Home
2016/10/26 全球购物
纽约家具、家居装饰和地毯店:ABC Carpet & Home
2017/06/21 全球购物
中学教师自我鉴定
2014/02/07 职场文书
《学会待客》教学反思
2014/02/22 职场文书
单位授权委托书范本
2014/09/26 职场文书
导游词400字
2015/02/13 职场文书
2015年语文教研组工作总结
2015/05/23 职场文书
工作经历证明范本
2015/06/15 职场文书
演讲开头怎么书写?
2019/08/06 职场文书
MySQL sql_mode的使用详解
2021/05/08 MySQL
Win10/Win11 任务栏替换成经典样式
2022/04/19 数码科技
vue项目如何打包之项目打包优化(让打包的js文件变小)
2022/04/30 Vue.js