如何将列表对象转换为具有已定义格式的Pandas Dataframe?
印刷清单有此输出(Jupyter):
(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)
转换为Pandas Dataframe:
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 :(得分:0)
清除列表中的内容后,您可以执行以下操作:
df = pd.DataFrame()
for key, df2 in row_list:
df2['index'] = key
df = df.append(df2, ignore_index=True)