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]


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM