Skip to content

Instantly share code, notes, and snippets.

View konstantinstadler's full-sized avatar

Konstantin Stadler konstantinstadler

View GitHub Profile
@konstantinstadler
konstantinstadler / exio2RoWto3RoW.py
Last active August 3, 2021 07:43
converting exiobase 2 letter RoW codes to 3 letters
import country_converter
import pandas as pd
custom_mapping = pd.DataFrame.from_dict(
{
"name_short": ["Africa", "Latin"],
"name_official": ["RoW Africa", "RoW Latin America"],
"regex": ["restafrica", "restlatin"],
"ISO2": ["WA", "WL"],
@konstantinstadler
konstantinstadler / add_class_coco.py
Created April 9, 2021 12:07
Example script for how to parse data to add a new classification column to the country converter coco: https://github.com/konstantinstadler/country_converter
""" Parse Global Health Data Exchange (GHDx) / Global Burden of Disease (GBD) numeric country codes for coco
This needs only to be done once, but might be a good guide for other inputs as well
Data sources:
- GHDx: http://ghdx.healthdata.org/
- Codebook with country codes: ghdx.healthdata.org/sites/default/files/ihme_query_tool/IHME_GBD_2019_CODEBOOK.zip
"""
@konstantinstadler
konstantinstadler / Yvectorchange.py
Created September 27, 2019 11:33
Changing Y vector
In [1]: import pymrio
In [2]: tt = pymrio.load_test().calc_all()
In [3]: tnew = tt.copy()
In [4]: Ynew = tnew.Y.copy()
In [5]: Ynew.loc['reg1', 'reg1'] = Ynew.loc['reg1', 'reg1'].values * 2