Suppose dict = {'A':{1,2,4}, 'B':{5,6}}
, How to create a Pandas Dataframe like this:
JavaScript
x
4
1
Key Value
2
0 'A' {1,2,4}
3
1 'B' {5,6}
4
Advertisement
Answer
Try:
JavaScript
1
5
1
dct = {"A": {1, 2, 4}, "B": {5, 6}}
2
3
df = pd.DataFrame({"Key": dct.keys(), "Value": dct.values()})
4
print(df)
5
Prints:
JavaScript
1
4
1
Key Value
2
0 A {1, 2, 4}
3
1 B {5, 6}
4