Skip to content

Main

View or edit on GitHub

This page is synchronized from trase/models/argentina/corn/main.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).

%configure_logging

from trase.tools.sps import SupplyChain

for year in [2015, 2016, 2017, 2018, 2019]:
    supplychain = SupplyChain("argentina/corn", year)
    supplychain.preparation()
    supplychain.load()
    # supplychain.flow_report_by_attribute("vol_bean", ["product_type"], significant_digits=10)
    supplychain.run()
    supplychain.flow_report_by_attribute(
        "vol_bean", ["status", "branch"], significant_digits=10
    )
    supplychain.export_results()
    # supplychain.upload_results()
import os
import pandas as pd

os.getcwd()
df = pd.read_csv(
    "/usr/share/TRASE/trase/models/argentina/corn/2016/prepared/flows.csv", sep=";"
)
# df = supplychain.get("exporter")

# df.head()
# df_assets.head()
# df = df.groupby(["exporter_name"]).agg(sum)
# df = df.sort_values("vol_bean", ascending=False)
df = df[df["province"] == "SALTA"]
df = df[df["country_of_destination"] == "BOLIVIA"]
df = df[df["exporter_name"] == "UNKNOWN"]
# missing_rows = df[df["exporter"] == "0"]
# df = df[["exporter_name", "customs_office.customs_office", "country_of_destination", "product_type", "vol_bean", "province.name"]]
# missing_rows
df
df = supplychain.get("flows")
print(list(df))
df[["department_of_production.trase_id"]]

Sankey

from trase.tools.jupyter.observable import sankey

df = supplychain.get("flows")
sankey(
    df,
    "vol_bean",
    [
        "department_of_production.province.name",
        "exporter_name",
        "country_of_destination",
    ],
)

Chloropleth

from trase.tools.sps import consolidate, rename
from trase.tools.jupyter.observable import notebook

df = supplychain.get("flows")
df = df[df["exporter.cuit"] == "3350673744"].copy()  # NIDERA ARGENTINA
df = consolidate(df, ["vol_bean"], ["department_of_production.geocode"])
df = rename(df, {"department_of_production.geocode": "id", "vol_bean": "value"})
notebook(
    "@trase/choropleth-canvas",
    ["chart"],
    {"country": "argentina", "width": 1500, "data": df.to_dict("records")},
)