python的pandas工具包,保存.csv文件時(shí)不要表頭的實(shí)例
用pandas處理.csv文件時(shí),有時(shí)我們希望保存的.csv文件沒有表頭,于是我去看了DataFrame.to_csv的document。
發(fā)現(xiàn)只需要再添加header=None這個(gè)參數(shù)就行了(默認(rèn)是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 ‘a(chǎn)scii' 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文件時(shí)不要表頭的實(shí)例就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
win8.1安裝Python 2.7版環(huán)境圖文詳解
在本篇內(nèi)容里小編給大家分享了關(guān)于win8.1安裝Python 2.7版環(huán)境的詳細(xì)步驟和方法,有興趣的朋友們跟著學(xué)習(xí)下。2019-07-07python 接口實(shí)現(xiàn) 供第三方調(diào)用的例子
今天小編就為大家分享一篇python 接口實(shí)現(xiàn) 供第三方調(diào)用的例子,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2019-08-08Python Scrapy框架:通用爬蟲之CrawlSpider用法簡(jiǎn)單示例
這篇文章主要介紹了Python Scrapy框架:通用爬蟲之CrawlSpider用法,結(jié)合實(shí)例形式分析了Scrapy框架中CrawlSpider的基本使用方法,需要的朋友可以參考下2020-04-04LyScript實(shí)現(xiàn)內(nèi)存交換與差異對(duì)比的方法詳解
LyScript?針對(duì)內(nèi)存讀寫函數(shù)的封裝功能并不多,只提供了內(nèi)存讀取和內(nèi)存寫入函數(shù)的封裝,本篇文章將繼續(xù)對(duì)API進(jìn)行封裝,實(shí)現(xiàn)一些在軟件逆向分析中非常實(shí)用的功能,需要的可以參考一下2022-08-08Python 機(jī)器學(xué)習(xí)庫(kù) NumPy入門教程
在我們使用Python語言進(jìn)行機(jī)器學(xué)習(xí)編程的時(shí)候,這是一個(gè)非常常用的基礎(chǔ)庫(kù)。本文針對(duì)Python 機(jī)器學(xué)習(xí)庫(kù) NumPy入門教程,感興趣的朋友跟隨腳本之家小編一起學(xué)習(xí)吧2018-04-04Python標(biāo)準(zhǔn)庫(kù)之隨機(jī)數(shù) (math包、random包)介紹
這篇文章主要介紹了Python標(biāo)準(zhǔn)庫(kù)之隨機(jī)數(shù) (math包、random包)介紹,本文講解了math包的常用函數(shù),同時(shí)給出了random包的使用例子,需要的朋友可以參考下2014-11-11Python高級(jí)技巧之利用psutil和subprocess實(shí)現(xiàn)程序監(jiān)控與管理
本文介紹了如何使用Python的psutil和subprocess模塊監(jiān)控程序運(yùn)行狀態(tài),并提供了一個(gè)案例腳本,用于監(jiān)控目標(biāo)程序并在停止時(shí)自動(dòng)重啟,詳細(xì)介紹了subprocess模塊的基本用法和psutil模塊的系統(tǒng)信息獲取、進(jìn)程管理及資源監(jiān)控功能,需要的朋友可以參考下2024-09-09Python?tkinter中四個(gè)常用按鈕的用法總結(jié)
tkinter中有四個(gè)控件被冠以Button之名,分別是:Button,?Checkbutton,?Radiobutton,?Menubutton,下面小編就來和大家聊聊它們的具體用法,感興趣的可以學(xué)習(xí)一下2023-09-09python3.7中安裝paddleocr及paddlepaddle包的多種方法
這篇文章主要介紹了python3.7中安裝paddleocr及paddlepaddle包,本文通過多種方法給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-11-11