2016-05-26 5 views
0

リストオブジェクトを定義された形式のPandas Dataframeに変換するには?リストオブジェクトを定義された形式のPandas Dataframeに変換するには?

印刷されたリストは、この出力(Jupyter)を持つ:

パンダDATAFRAMEに変換
(u'variable', price threshold 
0 13.5  100.0 
1 10.0  NaN) 
(u'standard', price threshold 
0 12.5  300.0 
1 11.0  NaN) 
(u'fixed', price threshold 
0 14.5  250.0 
1 10.1  200.0 
2 9.0  NaN) 
(u'standing-charge', price 
0  9) 

0    1 
0 variable  price threshold 0 13.5 100.0 1 10... 
1 standard  price threshold 0 12.5 300.0 1 11... 
2 fixed   price threshold 0 14.5 250.0 1 10... 
3 standing-charge price 0 9 

私が必要:

type  price threshold 
variable 13.5 100 
variable 10.0 NaN 
... 

、助けてください;)

+0

これらのリストの要素は何ですか?データフレーム? – MaxNoe

+0

ああ、あなたのインデックスはDataFrameが一意でなければならないので、あなたの「私は必要」はできません。インデックスの rows_list = [] 、ds.iterrowsの行(): = {} =行[ '平面']、json_normalize(行[ '速度']) – MaxNoe

+0

はJSONファイルを解析からの出力です rows_list.append(a) print rows_list –

答えて

0

あなたがクリアした後帽子があなたのリストにある場合、次のようなことができます:

df = pd.DataFrame() 
for key, df2 in row_list: 
    df2['index'] = key 
    df = df.append(df2, ignore_index=True) 
+0

あなたのためにビール!ありがとう!!! –

関連する問題