Skip to content

Commit

Permalink
total health spending indicators
Browse files Browse the repository at this point in the history
  • Loading branch information
jm-rivera committed Jan 27, 2023
1 parent 9f0dfd0 commit 2635736
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions scripts/total_health_spending.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
from functools import partial

import pandas as pd

from scripts import config
from scripts.indicators import get_current_health_exp
from scripts.tools import (
lcu2gdp,
mn2units,
year2date,
lcu2usd_current,
lcu2usd_constant,
value2pc,
)

health_exp_current_lcu = partial(
get_current_health_exp, additional_filter={"units": "national currency unit"}
)


def save_spending_data_versions() -> None:
"""Save versions of the LCU data"""
# Local currency units
data = {"lcu": health_exp_current_lcu().pipe(year2date).pipe(mn2units)}

# Share of GDP
data["gdp_share"] = data["lcu"].pipe(lcu2gdp)

# USD current
data["usd_current"] = data["lcu"].pipe(lcu2usd_current).assign(units="USD")

# USD constant
data["usd_constant"] = (
data["lcu"]
.pipe(lcu2usd_constant)
.assign(units=f"{config.CONSTANT_YEAR} constant USD")
)

# USD constant per capita
data["usd_constant_pc"] = data["usd_constant"].pipe(value2pc)

# Save
for key, value in data.items():
value.to_feather(config.PATHS.output / f"health_spending_{key}.feather")


def read_spending_data_versions() -> dict[str, pd.DataFrame]:
"""Read versions of the LCU data"""
return {
key: pd.read_feather(config.PATHS.output / f"health_spending_{key}.feather")
for key in [
"lcu",
"gdp_share",
"usd_current",
"usd_constant",
"usd_constant_pc",
]
}


if __name__ == "__main__":
# save_spending_data_versions()

spending = read_spending_data_versions()

0 comments on commit 2635736

Please sign in to comment.