Main
View or edit on GitHub
This page is synchronized from trase/models/argentina/soy/main.ipynb. Last modified on 2025-12-13 00:30 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/soy", year)
supplychain.preparation()
supplychain.load()
supplychain.run()
supplychain.flow_report_by_attribute(
"vol_bean", ["status", "branch"], significant_digits=10
)
supplychain.export_results()
supplychain.upload_results()
import pandas as pd
supplychain.upload_results()
import pandas as pd
from trase.tools.sps import SupplyChain
df = supplychain.get("flows")
# df.head()
# df_assets.head()
# df = df.groupby(["exporter_name"]).agg(sum)
# df = df.sort_values("vol_bean", ascending=False)
df = df[df["branch"] == "2.2.1"]
df = df[
[
"exporter_name",
"customs_office.customs_office",
"country_of_destination",
"product_type",
"vol_bean",
"province.name",
]
]
df
import pandas as pd
import os
os.getcwd()
df = pd.read_csv(
"/usr/share/TRASE/trase/models/argentina/soy/2018/results/results.csv", sep=";"
)
# df = df[df["LVL3_TRASE_ID_PROD"]== "AR-STOCK"]
df.head()
df = df.groupby(["BRANCH"]).agg(sum)
df = df.sort_values("VOLUME_TRADED", ascending=False)
df
# destined_for_quequen = df['ZONE_DESTINATION'] == 'QUEQUEN'
# origin_not_linked_to_quequen = ~df['ZONE_ORIGIN'].isin(['QUEQUEN', 'ZONA 3', 'ZONA 4'])
# should_exclude_quequen = destined_for_quequen & origin_not_linked_to_quequen
# df = df[~should_exclude_quequen]
# df[df['destination'] == "B BLANCA"]
Sankey
from trase.tools.sps 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")},
)