2017-03-12 267 views
0

我有以下的熊貓數據框:熊貓字典到數據幀

            Data 
0 {'high': 630.99, 'low': 596.57, 'open': 624.79... 
1 {'high': 612.55, 'low': 607.06, 'open': 608.52... 
2 {'high': 612.40, 'low': 605.92, 'open': 608.23... 
... 

如何將其轉化爲像一個數據幀:

high low open ... 
0 630.99 596.57 624.79 ... 
1 612.55 607.06 608.52 ... 
2 612.40 605.92 608.23 ... 
+0

你的問題是什麼?你有什麼嘗試? – DyZ

回答

1

你可以先通過values轉換dictnumpy array,然後list和最後使用DataFrame構造函數:

df = pd.DataFrame(df.Data.values.tolist(), index=df.index) 
print (df) 
    high  low open 
0 630.99 596.57 624.79 
1 612.55 607.06 608.52 
2 612.40 605.92 608.23