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