read_csv
# 函數原型
pandas
.
read_csv
(
filepath_or_buffer
,
sep
=
', '
,
delimiter
=
None
,
header
=
'infer'
,
names
=
None
,
index_col
=
None
,
usecols
=
None
,
squeeze
=
False
,
prefix
=
None
,
mangle_dupe_cols
=
True
,
dtype
=
None
,
engine
=
None
,
converters
=
None
,
true_values
=
None
,
false_values
=
None
,
skipinitialspace
=
False
,
skiprows
=
None
,
skipfooter
=
0
,
nrows
=
None
,
na_values
=
None
,
keep_default_na
=
True
,
na_filter
=
True
,
verbose
=
False
,
skip_blank_lines
=
True
,
parse_dates
=
False
,
infer_datetime_format
=
False
,
keep_date_col
=
False
,
date_parser
=
None
,
dayfirst
=
False
,
iterator
=
False
,
chunksize
=
None
,
compression
=
'infer'
,
thousands
=
None
,
decimal
=
b
'.'
,
lineterminator
=
None
,
quotechar
=
'"'
,
quoting
=
0
,
doublequote
=
True
,
escapechar
=
None
,
comment
=
None
,
encoding
=
None
,
dialect
=
None
,
tupleize_cols
=
None
,
error_bad_lines
=
True
,
warn_bad_lines
=
True
,
delim_whitespace
=
False
,
low_memory
=
True
,
memory_map
=
False
,
float_precision
=
None
)
常用參數
filepath_or_buffer
:通常為文件路徑
sep
:分隔符
header
:列名所在的行號。 默認為0(第一行),如果沒有則設置為
None
names
:用于結果的列名列表,對各列重命名,即添加表頭。如數據有表頭,但想用新的表頭,可以設置
header=0,names=['a','b']
實現表頭定制。
index_col
:用作行名(即行索引)的列編號或者列名。默認為
None
usecols
:需要讀取的列??稍O置為
usecols=[1,2]
或
usercols=['a','b']
encoding
:編碼格式。【通常應該手動設置為
"utf8"
】
to_csv
# 函數原型
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
=
'.'
)
常用參數
path_or_buf
:通常為文件路徑
sep
:分隔符
columns
:需要寫的列。默認為全部。
header
:是否保存列名。布爾值或者字符串列表。默認為
TRUE
,即保存列名。如果參數為字符串列表,則將列名一一替換成字符串并保存。
index
:是否保存行名,布爾值。默認為
TRUE
encoding
:編碼格式【通常應該手動設置為
"utf8"
】
參考文獻
1. http://www.voidcn.com/article/p-bnoadxrc-bqt.html
更多文章、技術交流、商務合作、聯系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號聯系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元
