Process JSON in PYGAL__JS

Source: Internet
Author: User
Import JSON from Random_walk import Get_country_code to Pygal.maps.world import world from Pygal.style import rotatestyl E from Pygal.style import lightcolorizedstyle #from pygal.style import Rotatestyle as rs,lightcolorstyle as LCS filename = ' Population_data.json ' with open (filename) as F:pop_data = Json.load (f) cc_population={} to Pop_dict in Pop_data : If pop_dict[' year '] = = ': country_name = pop_dict[' country name '] population = int (float (pop_di ct[' Value ']) code = Get_country_code (country_name) if Code:cc_population[code]=population C c_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]=pop print (len (cc_1), Len (cc_2), Len (cc_3)) #wm =world () #set The basic color #wm_style = Rotatestyle (' #336699 ') #brighten the Backgroudcolor #wm_style = Lightcolorizedstyle wm_styl E = Rotatestyle (' #336699', Base_style=lightcolorizedstyle) Wm=world (style=wm_style) Wm.title = "World population in 2010,by Country" #wm. Add (' 20 cc_population) #group The Data wm.add (' 0-10m ', cc_1) wm.add (' 10m-1bn ', cc_2) wm.add (' >1bn ', cc_3) wm.render_to_
 File (' World_population.svg ')

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.