有這本詞典
{'ON': time atm rr25 bf25 rr10 bf10
0 2022-03-29 23:00:00 0.0895 -0.008 0.0015 -0.014 0.004,
'1W': time atm rr25 bf25 rr10 bf10
0 2022-03-29 23:00:00 0.0785 -0.01 0.002 -0.017 0.0065,
'2W': time atm rr25 bf25 rr10 bf10
0 2022-03-29 23:00:00 0.0795 -0.011 0.0025 -0.019 0.00837,
'1M': time atm rr25 bf25 rr10 bf10
0 2022-03-29 23:00:00 0.077 -0.0115 0.0025 -0.0207 0.00925,
'2M': time atm rr25 bf25 rr10 bf10
0 2022-03-29 23:00:00 0.075 -0.0115 0.0025 -0.0207 0.00937,
'3M': time atm rr25 bf25 rr10 bf10
0 2022-03-29 23:00:00 0.07325 -0.012 0.00255 -0.0222 0.00969,
'6M': time atm rr25 bf25 rr10 bf10
0 2022-03-29 23:00:00 0.07175 -0.0125 0.00265 -0.02375 0.0102,
'9M': time atm rr25 bf25 rr10 bf10
0 2022-03-29 23:00:00 0.07125 -0.0125 0.00295 -0.02375 0.0115,
'1Y': time atm rr25 bf25 rr10 bf10
0 2022-03-29 23:00:00 0.071 -0.0125 0.003 -0.02381 0.0117,
'2Y': time atm rr25 bf25 rr10 bf10
0 2022-03-29 23:00:00 0.072 -0.0125 0.0032 -0.02375 0.01248}
我想把它轉換成這個dataFrame

我通過使用 pd.DataFrame.from_dict 嘗試了不同的方法,但沒有幫助
uj5u.com熱心網友回復:
使用pd.concat:
df = pd.concat(data).droplevel(1)
輸出:
>>> df
time atm rr25 bf25 rr10 bf10
ON 2022-03-29 23:00:00 0.0895 -0.008 0.0015 -0.014 0.0040
1W 2022-03-29 23:00:00 0.0785 -0.010 0.0020 -0.017 0.0065
資料
>>> data
{'ON': time atm rr25 bf25 rr10 bf10
0 2022-03-29 23:00:00 0.0895 -0.008 0.0015 -0.014 0.004,
'1W': time atm rr25 bf25 rr10 bf10
0 2022-03-29 23:00:00 0.0785 -0.01 0.002 -0.017 0.0065}
uj5u.com熱心網友回復:
你能澄清你輸入的格式嗎?在我看來,它不像字典。
另外,嘗試:
pd.DataFrame(data).T
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/453421.html
上一篇:熊貓資料框-添加其他?
