【发布时间】:2019-11-17 04:38:45
【问题描述】:
Excel 示例:
name empid office
ABC 1111 CTS
XYZ 2222 TCS
我想要字典中的值,例如:
row1={ name='ABC', empid=1111, office='CTS' }
row2={ name='XYZ', empid=2222, office='TCS' }
使用循环,一次一行。
我的代码:
import pandas as pd
dfs = pd.read_excel('E://Python Workspace//pythonReadExcel.xlsx', skiprows=0)
print(dfs.to_dict())
输出:
{'name': {0: 'ABC', 1: 'XYZ'}, 'empid': {0: 1111, 1: 2222}, 'office': {0: 'CTS', 1: 'TCS'}}
请帮我解决这个问题。
【问题讨论】: