python中pandas工具包如何實現(xiàn)保存.csv文件時不要表頭-創(chuàng)新互聯(lián)

小編給大家分享一下python中pandas工具包如何實現(xiàn)保存.csv文件時不要表頭,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!

創(chuàng)新互聯(lián)2013年開創(chuàng)至今,先為西林等服務(wù)建站,西林等地企業(yè),進(jìn)行企業(yè)商務(wù)咨詢服務(wù)。為西林企業(yè)網(wǎng)站制作PC+手機+微官網(wǎng)三網(wǎng)同步一站式服務(wù)解決您的所有建站問題。

用pandas處理.csv文件時,有時我們希望保存的.csv文件沒有表頭,于是我去看了DataFrame.to_csv的document。

發(fā)現(xiàn)只需要再添加header=None這個參數(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工具包如何實現(xiàn)保存.csv文件時不要表頭”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對大家有所幫助,如果還想學(xué)習(xí)更多知識,歡迎關(guān)注創(chuàng)新互聯(lián)成都網(wǎng)站設(shè)計公司行業(yè)資訊頻道!

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機、免備案服務(wù)器”等云主機租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。

網(wǎng)站題目:python中pandas工具包如何實現(xiàn)保存.csv文件時不要表頭-創(chuàng)新互聯(lián)
網(wǎng)站路徑:http://muchs.cn/article18/cdigdp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供App開發(fā)面包屑導(dǎo)航、網(wǎng)站營銷、網(wǎng)站排名電子商務(wù)、ChatGPT

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

網(wǎng)站托管運營