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中多线程及程序锁浅析
Jan 21 Python
Python异常学习笔记
Feb 03 Python
Python中的字符串查找操作方法总结
Jun 27 Python
浅析python递归函数和河内塔问题
Apr 18 Python
python 简单搭建阻塞式单进程,多进程,多线程服务的实例
Nov 01 Python
python遍历文件夹下所有excel文件
Jan 03 Python
Python实现的计算马氏距离算法示例
Apr 03 Python
使用 Python 快速实现 HTTP 和 FTP 服务器的方法
Jul 22 Python
Python序列对象与String类型内置方法详解
Oct 22 Python
python中rb含义理解
Jun 18 Python
基于python tkinter的点名小程序功能的实例代码
Aug 22 Python
python如何调用php文件中的函数详解
Dec 29 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
第九节--绑定
2006/11/16 PHP
php下通过POST还是GET来传值
2008/06/05 PHP
The specified CGI application misbehaved by not returning a complete set of HTTP headers
2011/03/31 PHP
PHP set_error_handler()函数使用详解(示例)
2013/11/12 PHP
Laravel 5框架学习之表单
2015/04/08 PHP
Smarty foreach控制循环次数的一些方法
2015/07/01 PHP
PHP实现阿里大鱼短信验证的实例代码
2017/07/10 PHP
Thinkphp开发--集成极光推送
2017/09/15 PHP
laravel框架模型中非静态方法也能静态调用的原理分析
2019/11/23 PHP
JQuery为textarea添加maxlength属性的代码
2010/04/07 Javascript
推荐11款jQuery开发的复选框和单选框美化插件
2011/08/02 Javascript
HTML页面登录时的JS验证方法
2014/05/28 Javascript
JavaScript通过Date-Mask将日期转换成字符串的方法
2015/06/04 Javascript
jQuery/JS监听input输入框值变化实例
2019/10/17 jQuery
[11:33]DAC2018 4.5SOLO赛决赛 MidOne vs Paparazi第二场
2018/04/06 DOTA
Python函数式编程指南(四):生成器详解
2015/06/24 Python
设计模式中的原型模式在Python程序中的应用示例
2016/03/02 Python
聊聊Python中的pypy
2018/01/12 Python
Python实现翻转数组功能示例
2018/01/12 Python
python3 读取Excel表格中的数据
2018/10/16 Python
Pyecharts绘制全球流向图的示例代码
2020/01/08 Python
Python简单实现区域生长方式
2020/01/16 Python
在Ubuntu 20.04中安装Pycharm 2020.1的图文教程
2020/04/30 Python
python3爬虫中多线程的优势总结
2020/11/24 Python
可自定义箭头样式的CSS3气泡提示框
2016/03/16 HTML / CSS
详解FireFox下Canvas使用图像合成绘制SVG的Bug
2019/07/10 HTML / CSS
Html5 audio标签样式的修改
2016/01/28 HTML / CSS
瑞典香水、须后水和美容产品购物网站:Parfym-Klick.se
2019/12/29 全球购物
请描述一下”is a”关系和”has a”关系
2015/02/03 面试题
制衣厂各岗位职责
2013/12/02 职场文书
受伤赔偿协议书
2014/09/24 职场文书
考试作弊检讨书
2015/01/27 职场文书
在职证明书模板
2015/06/15 职场文书
高老头读书笔记
2015/06/30 职场文书
Django实现WebSocket在线聊天室功能(channels库)
2021/09/25 Python
Linux7.6二进制安装Mysql8.0.27详细操作步骤
2021/11/27 MySQL