《Python数据分析实战》5 pandas:数据读写
- CSV
dat = pd.read_csv('temp.csv', header=0, names=['a','b','c'], sep='\t')
dat.to_csv('temp.csv', index=False, header=False)
- HTML
dat = pd.read_html('temp.html')
dat.to_html()
- EXCEL
dat = pd.read_excel('temp.xls', 'Sheet1')
dat.to_excel('temp.xls')
- JSON
dat = pd.read_json('temp.json')
dat.to_json()
- PICKLE
import pickle / import cPickle as pickle
dat = pd.read_pickle('temp.pkl')
dat.to_pickle('temp.pkl')