Pandas_导入导出
2017-05-20 本文已影响78人
Ledestin
pandas可以读取与存取的资料格式有很多种,像csv、excel、json、html与pickle
等…
Demo.py
import pandas as pd #加载模块
#读取csv
data = pd.read_csv('student.csv')
#打印出data
print data
#将资料存取成pickle
data.to_pickle('student.pickle')
结果:
Student ID name age gender Unnamed: 4
0 1100 Kelly 22 Female NaN
1 1101 Clo 21 Female NaN
2 1102 Tilly 22 Female NaN
3 1103 Tony 24 Male NaN
4 1104 David 20 Male NaN
5 1105 Catty 22 Female NaN
6 1106 M 3 Female NaN
7 1107 N 43 Male NaN
8 1108 A 13 Male NaN
9 1109 S 12 Male NaN
10 1110 David 33 Male NaN
11 1111 Dw 3 Female NaN
12 1112 Q 23 Male NaN
13 1113 W 21 Female NaN