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中使用装饰器时需要注意的一些问题
May 11 Python
django通过ajax发起请求返回JSON格式数据的方法
Jun 04 Python
Python使用pygame模块编写俄罗斯方块游戏的代码实例
Dec 08 Python
virtualenv实现多个版本Python共存
Aug 21 Python
Python AES加密实例解析
Jan 18 Python
python按综合、销量排序抓取100页的淘宝商品列表信息
Feb 24 Python
Python实用技巧之利用元组代替字典并为元组元素命名
Jul 11 Python
Python爬取个人微信朋友信息操作示例
Aug 03 Python
Python中asyncio模块的深入讲解
Jun 10 Python
django 微信网页授权登陆的实现
Jul 30 Python
python模拟点击网页按钮实现方法
Feb 25 Python
利用python爬取有道词典的方法
Dec 08 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
咖啡产品发展的三大浪潮
2021/03/04 咖啡文化
实现了一个PHP5的getter/setter基类的代码
2007/02/25 PHP
php中mysql模块部分功能的简单封装
2011/09/30 PHP
解析PHP中的正则表达式以及模式匹配
2013/06/19 PHP
IIS6.0 开启Gzip方法及PHP Gzip函数分享
2014/06/08 PHP
PHP实现的操作数组类库定义与用法示例
2019/05/24 PHP
php实现大文件断点续传下载实例代码
2019/10/01 PHP
javascript 获取url参数和script标签中获取url参数函数代码
2010/01/22 Javascript
Javascript之旅 对象的原型链之由来
2010/08/25 Javascript
基于JQuery的6个Tab选项卡插件
2010/09/03 Javascript
jquery ajax return没有返回值的解决方法
2011/10/20 Javascript
jQuery写fadeTo示例代码
2014/02/21 Javascript
JavaScript 冒泡排序和选择排序的实现代码
2016/09/03 Javascript
微信小程序 触控事件详细介绍
2016/10/17 Javascript
实例解析Array和String方法
2016/12/14 Javascript
在DWR中实现直接获取一个JAVA类的返回值的两种方法
2016/12/25 Javascript
flag和jq on 的绑定多个对象和方法(必看)
2017/02/27 Javascript
JavaScript中使用参数个数实现重载功能
2017/09/01 Javascript
浅谈Vue.js 中的 v-on 事件指令的使用
2018/11/25 Javascript
解决mui框架中switch开关通过js控制开或者关状态时小圆点不动的问题
2019/09/03 Javascript
[01:25]DOTA2超级联赛专访iG 将调整状态找回自己
2013/06/05 DOTA
[03:04]DOTA2英雄基础教程 影魔
2013/12/11 DOTA
python保存二维数组到txt文件中的方法
2018/11/15 Python
解决python replace函数替换无效问题
2020/01/18 Python
python爬虫用mongodb的理由
2020/07/28 Python
用pip给python安装matplotlib库的详细教程
2021/02/24 Python
CSS3实现歌词进度文字颜色填充变化动态效果的思路详解
2020/06/02 HTML / CSS
阿迪达斯西班牙官方网站:adidas西班牙
2016/07/21 全球购物
英国网上电器商店:Electricshop
2020/03/15 全球购物
自我评价200字分享
2013/12/17 职场文书
淘宝好评语大全
2014/05/05 职场文书
反邪教标语
2014/06/23 职场文书
公司优秀员工获奖感言
2014/08/14 职场文书
小班上学期个人总结
2015/02/12 职场文书
办公室岗位职责范本
2015/04/11 职场文书
Python连续赋值需要注意的一些问题
2021/06/03 Python