“DataFrame GroupBy to Dictionary” Code-Antworten

DataFrame GroupBy to Dictionary

In [81]: df.groupby('Column1')['Column3'].apply(list).to_dict()
Out[81]: {0: [1], 1: [2, 3, 5], 2: [1, 2], 3: [4, 5], 4: [1], 5: [1, 2, 3]}
Fantastic Fish

Konvertieren Sie die Pandas -Gruppe in dikte

res = dict(tuple(d.groupby('a')))
Magnificent Moth

DataFrame GroupBy to Dictionary

In [433]: {k: list(v) for k, v in df.groupby('Column1')['Column3']}
Out[433]: {0: [1], 1: [2, 3, 5], 2: [1, 2], 3: [4, 5], 4: [1], 5: [1, 2, 3]}
Fantastic Fish

Ähnliche Antworten wie “DataFrame GroupBy to Dictionary”

Fragen ähnlich wie “DataFrame GroupBy to Dictionary”

Weitere verwandte Antworten zu “DataFrame GroupBy to Dictionary” auf Python

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen