3
Ich bin ein Datenrahmen zu schaffen und dann zu einem Wörterbuch Umwandlung wie untenPython Datenrahmen zu Wörterbuch, Schlüsselwert Ausgabe
data = {'ID': [1,2,3,4,5],
'A':['1','2','1','3','2'],
'B':[4,6,8,2,4]}
frame = pd.DataFrame(data)
dict_obj = dict(frame[['A','B']].groupby('A').median().sort_values(by='B'))
Mein Problem ist, dass ich Spalte A als Key und Spalte B als Werte wollen, aber irgendwie bin ich immer eine seltsame Wörterbuch
dict_obj
{'B': A
3 2
2 5
1 6
Name: B, dtype: int64}
ich will Wörterbuch Objekt als
{1:6,2:5,3:2}
Könnte jemand h bitte, bitte?