import pandas as pd

# 结构类似:{“南京”:{"男":12,“女”:33},}
dic = {}
data = pd.read_excel("./11.xlsx").as_matrix()
for line in data:
    if line[1] not in dic:
        dic[line[1]] = {}
    if line[-1] not in dic[line[1]]:
        dic[line[1]][line[-1]] = {"": 0, "": 0}
    if line[-2] == "":
        dic[line[1]][line[-1]][""] += 1
    else:
        dic[line[1]][line[-1]][""] += 1
print(dic)

 

相关文章:

  • 2021-12-05
  • 2021-10-07
  • 2021-06-08
  • 2022-01-07
  • 2021-07-16
  • 2022-12-23
  • 2021-07-08
猜你喜欢
  • 2022-12-23
  • 2021-12-12
  • 2021-12-10
  • 2022-12-23
  • 2021-04-24
  • 2021-12-23
  • 2021-09-22
相关资源
相似解决方案