Last active
September 18, 2021 18:11
-
-
Save hbshrestha/e08ee59bd6f567042bce0e55f5120962 to your computer and use it in GitHub Desktop.
world bank dataset
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pandas_datareader import wb | |
import pandas as pd | |
#Indicators: GDP, GDP per capita, access to electricity, population, CO2 emissions | |
indicators = ["NY.GDP.MKTP.CD", "NY.GDP.PCAP.CD", "EG.ELC.ACCS.ZS", | |
"SP.POP.TOTL", "EN.ATM.CO2E.KT"] | |
#ISO Code of countries: Australia, Bhutan, Germany, France, Indonesia, India, Japan, | |
#Korea, Netherlands, Nepal, Russia, South Africa | |
countries = ["AUS", "BTN", "DEU", "FRA", "IDN", "IND", "JPN", | |
"KOR", "NPL", "NLD", "RUS", "ZAF"] | |
df = wb.download(country = countries, | |
indicator = indicators, | |
start = 2018, | |
end = 2018) | |
df.rename({"NY.GDP.MKTP.CD":"GDP", | |
"NY.GDP.PCAP.CD":"GDP per capita", | |
"EG.ELC.ACCS.ZS":"Access to electricity", | |
"SP.POP.TOTL": "Population", | |
"EN.ATM.CO2E.KT": "kt CO2"}, | |
axis = 1, inplace = True) | |
df.index = df.index.get_level_values(0) | |
df |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment