Valuebai / awesome-python-io

Python十分钟入门指南/技术图谱,持续更新收集整理中,期待你的参与
MIT License
8 stars 1 forks source link

【pandas】怎么把Excel中的两列字段变成字典形式 #18

Open Valuebai opened 4 years ago

Valuebai commented 4 years ago

本地有个Excel表格,有两列数据,我如何读取到pandas中,并且做成字典的格式。 image

原始数据想要的格式 image

test1 = pd.read_excel('路径',sheetname = 'test')

test1.set_index("Id").to_dict()['映射'] image