1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| import pandas as pd a = np.arange(1,26,1) a = a.reshape((5,5))
b = pd.DataFrame(a,columns=['i1','i2','i3','i4','i5'])
b.to_csv('./Data/tmp_1.csv')
b.to_csv('./Data/tmp_2.csv',index =False,header=False)
b.to_csv('./Data/tmp_3.csv',na_rep="空")
csvframe = pd.read_csv('./Data/tmp_1.csv') print(csvframe, "\n-----*-----") csvframe = pd.read_table('./Data/tmp_1.csv',sep=',') print(csvframe, "\n-----*-----")
csvframe = pd.read_csv('./Data/tmp_2.csv',header=None) print(csvframe, "\n-----*-----")
csvframe = pd.read_csv('./Data/tmp_2.csv',names=['d1','d2','d3','d4','d5','d6']) print(csvframe, "\n-----*-----")
csvframe = pd.read_csv('./Data/tmp_3.csv',index_col=['i1','i2']) print(csvframe, "\n-----*-----")
|