Python Dataframe转List

 1 from pandas import read_csv
 2 
 3 dataframe = read_csv(r'url', nrows = 86400, usecols = [0,], engine='python')
 4 #nrows:读取行数,usecols=[n,]:仅读取第n列,usecols=[a,b,c]:读取a、b、c列
 5 dataset = dataframe.values
 6 
 7 List = []
 8 for k in dataset: 
 9     for j in k: 
10         List.append(j)
11 
12 print(dataframe[0:3])
13 print(dataset[0:3])
14 print(List[0:3])

得到结果:

 FIT101(属性名)
0     0.0
1     0.0
2     0.0
[[ 0.]
 [ 0.]
 [ 0.]]
[0.0, 0.0, 0.0]
posted @ 2018-05-07 14:00  Infinite666  阅读(14731)  评论(0编辑  收藏  举报