Skip to content

View or edit on GitHub

This page is synchronized from trase/models/bolivia/soy/QA.ipynb. Last modified on 2025-12-14 23:19 CET by Trase Admin. Please view or edit the original file there; changes should be reflected here after a midnight build (CET time), or manually triggering it with a GitHub action (link).

import pandas as pd
from trase.tools import sps
import plotly.express as px

df = sps.concat(
    pd.read_csv(f"{year}/results/results.csv", sep=";", dtype=str)
    for year in [2018, 2019, 2020, 2021]
)
df = df.astype({"vol_tn": float})

display(
    px.bar(
        sps.consolidate(df, ["vol_tn"], ["year", "branch"]),
        x="year",
        y="vol_tn",
        color="branch",
        title="Breakdown of branches per year",
    )
)

Compare to previous model run (in ~March)

df_old = sps.concat(
    sps.get_pandas_df_once(key, sep=";", dtype=str, version_id=version)
    for (key, version) in [
        (
            "bolivia/soy/sei_pcs/v1.0.0/SEIPCS_BOLIVIA_SOY_2018.csv",
            "hhJzjHhAivIg7UdD.xVCoZAMeAc59KCm",
        ),
        (
            "bolivia/soy/sei_pcs/v1.0.0/SEIPCS_BOLIVIA_SOY_2019.csv",
            "ZwOdydHak7UMgnSkDz1DKpRS_XdLYbsg",
        ),
        (
            "bolivia/soy/sei_pcs/v1.0.0/SEIPCS_BOLIVIA_SOY_2020.csv",
            ".qlly5.x0tTJn2mUPexiMJJ5nL_DTVId",
        ),
        (
            "bolivia/soy/sei_pcs/v1.0.0/SEIPCS_BOLIVIA_SOY_2021.csv",
            "Q_GG7cZg5HqXYUhNKVSzY38HGkzKJ5de",
        ),
    ]
)
df_old = df_old.astype({"vol_tn": float})
year = 2018
sps.dumbbell_compare(
    df_old[df_old["year"].astype(int) == year],
    df[df["year"].astype(int) == year],
    "vol_tn",
    ["municipality"],
    labels=("model run on March 21st", "new model run"),
    title_text=f"Volume tn allocated per municipality in {year}",
)
df_old[df_old["year"] == "2020"]["vol_tn"].sum()
df[df["year"] == "2020"]["vol_tn"].sum()