CounterをDictionary(辞書)に変換[Python]

import pandas as pd
from collections import Counter

d = Counter({'A': 1, 'B': 2, 'C': 3})
df = pd.DataFrame.from_dict(d, orient='index').reset_index()

print(df)

df.to_csv("data.csv")

出力

  index  0
0     A  1
1     B  2
2     C  3

Pandas,Python

Posted by vastee