# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# +
# Purpose = get population for any 10 countries using latest population numbers

# https://pypi.org/project/world-bank-data/
# https://github.com/mwouts/world_bank_data/blob/master/examples/A%20sunburst%20plot%20of%20the%20world%20population.ipynb

# IMPORTANT install the World Bank Data python package....pip install world_bank_data --upgrade
# -

import pandas as pd
import world_bank_data as wb
pd.set_option('display.max_rows', 6)

# +
#wb.get_countries()
#wb.get_incomelevels
#wb.get_topics()
#wb.get_indicators(topic=3, source=2)
# -

#population = wb.get_series('SP.POP.TOTL', mrv=1)
population = wb.get_series('SP.POP.TOTL', id_or_value='countries', simplify_index=True, mrv=1)
population[2:5]

df = countries[['region', 'name']].rename(columns={'name': 'country'}).loc[countries.region != 'Aggregates']
df['population'] = population
df

countries = ["CL","UY","HU"]
#indicators = {'NY.GNP.PCAP.CD':'GNI per Capita'}
indicators = {'SP.POP.TOTL'}

#df = wb.get_dataframe(indicators, country=countries, convert_date=False)
#data = {'Indicators': ['SP.POP.TOTL'], 'countries': ["CL","UY","HU"]}
#df = pd.DataFrame(data, columns=['Indicator', 'countries'])
#df = pd.DataFrame(boston.data, columns=boston.feature_names)
data = wb.get_dataframe({'SP.POP.TOTL':'values'}, 
                            country=('BGD', 'SAU'), 
                            data_date=data_dates, 
                            convert_date=False, keep_levels=True)
df = pd.DataFrame(data, columns=['Indicator', 'countries'])
df.head()

population = wb.get_series('SP.POP.TOTL', mrv=1)
population



StarcoderdataJupyterScriptsDedupFiltered