原始数据表格
pandas读取excel
to_dict方法不同入参最终展示结果(不输入参数时默认为dict)
import pandas as pd
def excelRead(path):
ex = pd.read_excel(path)
d0 = ex.to_dict('list')
d1 = ex.to_dict('dict')
d2 = ex.to_dict('series')
d3 = ex.to_dict('split')
d4 = ex.to_dict('records')
d5 = ex.to_dict('index')
d6 = ex.to_dict() #默认
print ('字典0:',d0)
print ('字典1:',d1)
print ('字典2:',d2)
print ('字典3:',d3)
print ('字典4:',d4)
print ('字典5:',d5)
print ('字典6:',d6)
if __name__ == '__main__':
path = "C:\\Users\\OP04\\Desktop\\升级数据规律.xlsx"
excelRead(path)