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插入数据到列表的方法
Apr 30 Python
深入解读Python解析XML的几种方式
Feb 16 Python
python脚本设置超时机制系统时间的方法
Feb 21 Python
Python中实例化class的执行顺序示例详解
Oct 14 Python
python 操作hive pyhs2方式
Dec 21 Python
python程序输出无内容的解决方式
Apr 09 Python
在matplotlib中改变figure的布局和大小实例
Apr 23 Python
Python学习之路安装pycharm的教程详解
Jun 17 Python
Python+Kepler.gl实现时间轮播地图过程解析
Jul 20 Python
python 实现关联规则算法Apriori的示例
Sep 30 Python
python语言实现贪吃蛇游戏
Nov 13 Python
Python编程编写完善的命令行工具
Sep 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
电脑硬件及电脑配置知识大全
2020/03/17 数码科技
从零开始学YII2框架(五)快速生成代码工具 Gii 的使用
2014/08/20 PHP
PHP实现支持GET,POST,Multipart/form-data的HTTP请求类
2014/09/24 PHP
PHP实现补齐关闭的HTML标签
2016/03/22 PHP
PHP书写格式详解(必看)
2016/05/23 PHP
laravel5 Eloquent 实现事务方式
2019/10/21 PHP
Laravel定时任务的每秒执行代码
2019/10/22 PHP
用javascript控制iframe滚动的代码
2007/04/10 Javascript
javaScript 判断字符串是否为数字的简单方法
2009/07/25 Javascript
capacityFixed 基于jquery的类似于新浪微博新消息提示的定位框
2011/05/24 Javascript
Jquery中删除元素的实现代码
2011/12/29 Javascript
js中复制行和删除行的操作实例
2013/06/25 Javascript
window.onresize 多次触发的解决方法
2013/11/08 Javascript
js判断手机端(Android手机还是iPhone手机)
2015/07/22 Javascript
使用CSS+JavaScript或纯js实现半透明遮罩效果的实例分享
2016/05/09 Javascript
全面了解构造函数继承关键apply call
2016/07/26 Javascript
基于D3.js实现时钟效果
2018/07/17 Javascript
详解vue2.0 资源文件assets和static的区别
2018/11/27 Javascript
angular 实现同步验证器跨字段验证的方法
2019/04/11 Javascript
微信小程序模板消息推送的两种实现方式
2019/08/27 Javascript
vue表单验证之禁止input输入框输入空格
2020/12/03 Vue.js
[01:32]DOTA2上海特锦赛现场采访:最想COS的英雄
2016/03/25 DOTA
[15:07]lgd_OG_m2_BP
2019/09/10 DOTA
Python深入学习之内存管理
2014/08/31 Python
详谈Pandas中iloc和loc以及ix的区别
2018/06/08 Python
Python 中的 global 标识对变量作用域的影响
2019/08/12 Python
Java文件与类动手动脑实例详解
2019/11/10 Python
俄罗斯厨房产品购物网站:COOK HOUSE
2021/03/15 全球购物
大学毕业生通用求职信
2013/09/28 职场文书
会计实习生自我鉴定
2013/12/12 职场文书
眼镜促销方案
2014/03/15 职场文书
大学生求职信
2014/06/17 职场文书
2016年12月份红领巾广播稿
2015/12/21 职场文书
canvas多重阴影发光效果实现
2021/04/20 Javascript
JavaScript执行机制详细介绍
2021/12/06 Javascript
windows server2012 R2下安装PaddleOCR服务的的详细步骤
2022/09/23 Servers