我有这样的字典:
dict = {(100,22,123):'55%',(110,24,123):'58%'}
例如,元组的元素是(x,y,z),值是某种错误率...我想打印那个字典,但我不是很清楚怎么做或采用何种格式(最好轻松查看信息,可能:x - y - z - 速率)。
我发现:Converting Dictionary to Dataframe with tuple as key,但我认为它不符合我的要求,我无法理解。
谢谢
答案 0 :(得分:0)
您可以将Series
与reset_index
一起使用,最后只设置新的列名:
import pandas as pd
d = {(100,22,123):'55%',(110,24,123):'58%'}
df = pd.Series(d).reset_index()
df.columns = ['a','b','c', 'd']
print (df)
a b c d
0 100 22 123 55%
1 110 24 123 58%