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]

转载于:https://www.cnblogs.com/wq14061023/p/9002281.html

你可能感兴趣的:(python)