Python Dataframe转List
生活随笔
收集整理的這篇文章主要介紹了
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 Dataframe转List的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 判断一个js对象,是否具有某个属性
- 下一篇: 梦到盘子碗碎了是什么意思