pandas转为字典格式

62 阅读1分钟
import pandas as pd
df=pd.read_excel('文件路径')
print(df.set_index(['词'])['频率'].to_dict())
#输出效果{'blackout': 176, 'light': 103}