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中获得当前目录和上级目录的实现方法
Oct 12 Python
matplotlib中legend位置调整解析
Dec 19 Python
Python使用matplotlib填充图形指定区域代码示例
Jan 16 Python
python抓取京东小米8手机配置信息
Nov 13 Python
判断python对象是否可调用的三种方式及其区别详解
Jan 31 Python
python二进制读写及特殊码同步实现详解
Oct 11 Python
将python包发布到PyPI和制作whl文件方式
Dec 25 Python
pandas中read_csv、rolling、expanding用法详解
Apr 21 Python
Python基础教程(一)——Windows搭建开发Python开发环境
Jul 20 Python
Python爬虫之爬取淘女郎照片示例详解
Jul 28 Python
python openCV自制绘画板
Oct 27 Python
Python try except finally资源回收的实现
Jan 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
PHP iconv 解决utf-8和gb2312编码转换问题
2010/04/12 PHP
php下获取Discuz论坛登录用户名、用户组、用户ID等信息的实现代码
2010/12/29 PHP
基于PHP读取TXT文件向数据库导入海量数据的方法
2013/04/23 PHP
关于JSON以及JSON在PHP中的应用技巧
2013/11/27 PHP
phpcms手机内容页面添加上一篇和下一篇
2015/06/05 PHP
PHP实现简单用户登录界面
2019/10/23 PHP
javascript利用apply和arguments复用方法
2013/11/25 Javascript
IE与FF下javascript获取网页及窗口大小的区别详解
2014/01/14 Javascript
把文本中的URL地址转换为可点击链接的JavaScript、PHP自定义函数
2014/07/29 Javascript
理解Javascript文件动态加载
2016/01/29 Javascript
JS通过Cookie判断页面是否为首次打开
2016/02/05 Javascript
Vue.js实现简单ToDoList 前期准备(一)
2016/12/01 Javascript
详解VueJS 数据驱动和依赖追踪分析
2017/07/26 Javascript
原生js jquery ajax请求以及jsonp的调用方法
2017/08/04 jQuery
vue中的计算属性的使用和vue实例的方法示例
2017/12/04 Javascript
webpack打包多页面的方法
2018/11/30 Javascript
p5.js码绘“跳动的小正方形”的实现代码
2019/10/22 Javascript
vue组件讲解(is属性的用法)模板标签替换操作
2020/09/04 Javascript
[02:09]EHOME夺得首届辉夜杯冠军—现场颁奖仪式
2015/12/28 DOTA
Python的Flask框架中使用Flask-Migrate扩展迁移数据库的教程
2016/06/14 Python
Python学习小技巧之列表项的拼接
2017/05/20 Python
python机器学习之神经网络(二)
2017/12/20 Python
python中文乱码不着急,先看懂字节和字符
2017/12/20 Python
Python内置模块ConfigParser实现配置读写功能的方法
2018/02/12 Python
python3+PyQt5实现柱状图
2018/04/24 Python
Python单元测试unittest的具体使用示例
2018/12/17 Python
关于python tushare Tkinter构建的简单股票可视化查询系统(Beta v0.13)
2020/10/19 Python
英国儿童家具专卖店:GLTC
2016/09/24 全球购物
6号汽车旅馆预订:Motel 6
2018/02/11 全球购物
印度购买眼镜和太阳镜网站:Coolwinks
2018/09/26 全球购物
莫斯科的韩国化妆品店:Sifo
2019/12/04 全球购物
主键(Primary Key)约束和唯一性(UNIQUE)约束的区别
2013/05/29 面试题
技术副厂长岗位职责
2013/12/26 职场文书
父亲追悼会答谢词
2014/01/17 职场文书
《学会待客》教学反思
2014/02/22 职场文书
优秀教师事迹材料
2014/12/15 职场文书