import pandas as pd
from pyecharts import options as opts
from pyecharts.charts import Map

df_tb = pd.read_excel('./data.xlsx')
def func(m):
    a = []
    for i in range(0, 35):
        b = (df_tb['地区'][i], int(df_tb[m][i]))
        a.append(b)
    return a

#
datas2 = func('2016年')
print('=============datas=============')
datas = [('全国', 832), ('北京', 0), ('天津', 0), ('河北', 45), ('山西', 36), ('内蒙古', 31), ('辽宁', 0), ('吉林', 8), ('黑龙江', 21), ('上海', 0), ('江苏', 0), ('浙江', 0), ('安徽', 20), ('福建', 0), ('江西', 24), ('山东', 0), ('河南', 38), ('湖北', 28), ('湖南', 40), ('广东', 0), ('广西', 33), ('海南', 5), ('重庆', 14), ('四川', 66), ('贵州', 66), ('云南', 88), ('西藏', 74), ('陕西', 56), ('甘肃', 58), ('青海', 41), ('宁夏', 8), ('新疆', 32), ('台湾', 0), ('香港', 0), ('澳门', 0)]

print(datas)

for data in datas:
    print(type(data[1]), end='')
print('\n')

print('=============datas2=============')
print(datas2)
for data in datas2:
    print(type(data[1]), end='')
#
# #
# # provinces = []
# # values = []
# #
# # for i in range(0, 35):
# #     location = df_tb['地区'][i]
# #     value = df_tb['2016年'][i]
# #     provinces.append(location)
# #     values.append(value)
# #
# # map = Map().add("gdp", [data for data in zip(provinces, values)], 'china')
# # map.render('datas2_各省贫困县分布图.html')
#
# from pyecharts.charts import Map, Geo
# from pyecharts import options as opts
# # data=[("广东",10430.03),("山东",9579.31),("河南",9402.36),("四川",8041.82),("江苏",7865.99),("河北",7185.42),("湖南",6568.37),("安徽",5950.1),("浙江",5442),("湖北",5723.77),("广西",4602.66),("云南",4596.6),("江西",4456.74),("辽宁",4374.63),("黑龙江",3831.22),("陕西",3732.74),("山西",3571.21),("福建",3552),("重庆",2884),("贵州",3476.65),("吉林",2746.22),("甘肃",2557.53),("内蒙古",2470.63),("上海",2301.391),("台湾",2316.2),("新疆",2181.33),("北京",1961.2),("天津",1293.82),("海南",867.15),("香港",709.76),("青海",562.67),("宁夏",630.14),("西藏",300.21),("澳门",55.23)]
# # data = [('全国', 832), ('北京', 0), ('天津', 0), ('河北', 45), ('山西', 36), ('内蒙古', 31), ('辽宁', 0), ('吉林', 8), ('黑龙江', 21), ('上海', 0), ('江苏', 0), ('浙江', 0), ('安徽', 20), ('福建', 0), ('江西', 24), ('山东', 0), ('河南', 38), ('湖北', 28), ('湖南', 40), ('广东', 0), ('广西', 33), ('海南', 5), ('重庆', 14), ('四川', 66), ('贵州', 66), ('云南', 88), ('西藏', 74), ('陕西', 56), ('甘肃', 58), ('青海', 41), ('宁夏', 8), ('新疆', 32), ('台湾', 0), ('香港', 0), ('澳门', 0)]
# # data_new = [('全国', 832), ('北京', 0), ('天津', 0), ('河北', 45), ('山西', 36), ('内蒙古', 31), ('辽宁', 0), ('吉林', 8), ('黑龙江', 21), ('上海', 0), ('江苏', 0), ('浙江', 0), ('安徽', 20), ('福建', 0), ('江西', 24), ('山东', 0), ('河南', 38), ('湖北', 28), ('湖南', 40), ('广东', 0), ('广西', 33), ('海南', 5), ('重庆', 14), ('四川', 66), ('贵州', 66), ('云南', 88), ('西藏', 74), ('陕西', 56), ('甘肃', 58), ('青海', 41), ('宁夏', 8), ('新疆', 32), ('台湾', 0), ('香港', 0), ('澳门', 0)]
#
map=(
    Map()
    .add("", datas2, "china")
    .set_global_opts(
        title_opts=opts.TitleOpts(title="各省市人口数", subtitle="数据来源：中国统计年鉴（万人）", pos_right="center", pos_top="5%"),
        visualmap_opts=opts.VisualMapOpts(max_=150),
    )
)
# map.render_notebook()
map.render('各省市人口数分布图.html')
