process json in pygal
来源:互联网 发布:面试常用的排序算法 编辑:程序博客网 时间:2024/06/05 14:27
import jsonfrom random_walk import get_country_codefrom pygal.maps.world import Worldfrom pygal.style import RotateStylefrom pygal.style import LightColorizedStyle#from pygal.style import RotateStyle as RS,LightColorStyle as LCSfilename = 'population_data.json'with open(filename) as f: pop_data = json.load(f)cc_population={}for pop_dict in pop_data: if pop_dict['Year'] == '2010': country_name = pop_dict['Country Name'] population = int(float(pop_dict['Value'])) code = get_country_code(country_name) if code: cc_population[code]=populationcc_1,cc_2,cc_3={},{},{}for cc,pop in cc_population.items(): if pop <10000000: cc_1[cc]=pop elif pop <1000000000: cc_2[cc]=pop else: cc_3[cc]=popprint(len(cc_1),len(cc_2),len(cc_3))#wm=World()#set the basic color#wm_style = RotateStyle('#336699')#brighten the backgroudcolor#wm_style = LightColorizedStylewm_style = RotateStyle('#336699',base_style=LightColorizedStyle)wm=World(style=wm_style)wm.title = "World population in 2010,by Country"#wm.add('2010',cc_population)#group the datawm.add('0-10m',cc_1)wm.add('10m-1bn',cc_2)wm.add('>1bn',cc_3)wm.render_to_file('World_population.svg')
阅读全文
0 0
- process json in pygal
- use api in pygal
- python处理JSON格式数据并利用pygal绘制世界地图
- python.json/pygal.maps.world学习范例-读取json格式文件、生成世界地图
- pygal-直方图
- Process management in Linux
- Process in Shell
- kill process in linux
- process csv in matplotlib
- detach process in nodejs
- sd--salea process in sd
- sd--salea process in sd
- QP:Error in formula process...
- Build process in Windows Mobile
- Build Process in Windows mobile
- operation now in process 问题;
- Build process in Windows Mobile
- UPRMS1 Process in Message Solving
- 几个公式(1)
- Maven详解
- 对Okhttp的封装Okhttp-utils
- 在channel标签中使用currentstyle中,不能输出自定义新变量
- Hadoop Hive sql操作
- process json in pygal
- MySQL主从复制与主主复制
- dedecms自定义表单加验证码
- raw_spin_lock_irqsave
- Exception in thread "http-bio-8082-exec-5" Exception in thread "QuartzScheduler_BUSINESS-sfi-PC15027
- iOS 检测设备静音状态
- java 第三天笔记
- 插入排序
- 用蓝牙构建一个sniffer来监听通话