一.文本讀寫
名稱 |
接收 |
代表(含義) |
默認(rèn) |
filepath |
string |
文件路徑 |
無 |
sep |
string |
分割符 |
',' |
header |
Int/sequence |
某行做列名 |
infer自動(dòng)尋找 |
names |
array, |
列名 |
None |
Index_col |
int,,sequence,F(xiàn)alse |
索引列的位置 |
None |
dtype |
Dict |
寫入數(shù)據(jù)類型 |
None |
enigne |
c/python |
數(shù)據(jù)解析引擎 |
c |
nrows |
int |
讀取前n行 |
Nome |
1.讀
(1)read_table
讀取txt格式
pd.read_table('文件地址/文件.txt')
(2)read_csv
讀取csv格式
pd.read_csv('文件地址/文件.csv')
2.寫
to_csv
可寫入txt,,csv格式
pd.to_csv('文件地址/文件.csv/txt')
二.Excel讀寫
參數(shù) |
接收 |
表示 |
默認(rèn) |
Io |
string |
文件路徑 |
無 |
Sheetname |
String/ int |
Excel內(nèi)部數(shù)據(jù)的分表位置 |
0 |
header |
Int /sequence |
某行數(shù)據(jù)做列名,,int時(shí)將該列做列名,sequence多重列索引 |
infer |
names |
array |
列名 |
None |
index_col |
Int/sequence/Flash |
索引列的位置,,sequenc時(shí)多重列索引 |
None |
dtype |
dict |
寫入的數(shù)據(jù)類型(列名key,,數(shù)據(jù)格式values) |
None |
1.Excel讀
read_excel
Excel常用格式xls,xlsx
pd.read_excel('文件地址/文件.xls/xlsx')
示例
2.Excel讀
to_excel
Excel常用格式xls,,xlsx
pd.to_excel('文件地址/文件.xls/xlsx')
示例
|