Main

View or edit on GitHub

This page is synchronized from trase/models/brazil/soy/main.ipynb. Last modified on 2026-06-20 06:32 CEST by GitHub Actions. 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).

from trase.tools import sps
from quality_assurance import quality_assurance

for year in [
    # 2019,
    # 2020,
    # 2021,
    2022,
]:
    try:
        print(f"Running {year}")
        supplychain = sps.SupplyChain("brazil/soy", year=year)
        supplychain.preparation()
        supplychain.load()
        supplychain.run()
        supplychain.flow_report_by_attribute("vol", ["branch"], 8)
        # supplychain.flow_report_by_attribute("vol", ["exporter_type"], 8)
        # supplychain.export_results()
        # quality_assurance(year)
        # supplychain.upload_results()
    except Exception as e:
        print(f"Failed {year}: {e}")
Running 2022
Extracting data from source ...  took 0.5 seconds
Skipping re-process of Municipality
Extracting data from source ...  took 0.3 seconds
Skipping re-process of PortMunicipality
Extracting data from source ...  took 0.3 seconds
Skipping re-process of Hs
Extracting data from source ...

/Users/jailsonsoares/repos/TRASE/trase/tools/etl/pandas_wrapper.py:162: FutureWarning: A value is trying to be set on a copy of a DataFrame or Series through chained assignment using an inplace method.
The behavior will change in pandas 3.0. This inplace method will never work because the intermediate object on which we are setting values always behaves as a copy.

For example, when doing 'df[col].method(value, inplace=True)', try using 'df.method({col: value}, inplace=True)' or df[col] = df[col].method(value) instead, to perform the operation inplace on the original object.


  df[column].replace("", np.nan, inplace=True)


     took 0.3 seconds
Skipping re-process of CommodityRatios


/Users/jailsonsoares/repos/TRASE/trase/tools/etl/pandas_wrapper.py:162: FutureWarning: A value is trying to be set on a copy of a DataFrame or Series through chained assignment using an inplace method.
The behavior will change in pandas 3.0. This inplace method will never work because the intermediate object on which we are setting values always behaves as a copy.

For example, when doing 'df[col].method(value, inplace=True)', try using 'df.method({col: value}, inplace=True)' or df[col] = df[col].method(value) instead, to perform the operation inplace on the original object.


  df[column].replace("", np.nan, inplace=True)


Extracting data from source ...  took 0.3 seconds
Skipping re-process of States
Extracting data from source ...

/Users/jailsonsoares/repos/TRASE/trase/tools/etl/pandas_wrapper.py:162: FutureWarning: A value is trying to be set on a copy of a DataFrame or Series through chained assignment using an inplace method.
The behavior will change in pandas 3.0. This inplace method will never work because the intermediate object on which we are setting values always behaves as a copy.

For example, when doing 'df[col].method(value, inplace=True)', try using 'df.method({col: value}, inplace=True)' or df[col] = df[col].method(value) instead, to perform the operation inplace on the original object.


  df[column].replace("", np.nan, inplace=True)


     took 0.3 seconds
Skipping re-process of ClosePorts
Extracting data from source ...  took 0.3 seconds
Skipping re-process of ExtraCnpjs


/Users/jailsonsoares/repos/TRASE/trase/tools/etl/pandas_wrapper.py:162: FutureWarning: A value is trying to be set on a copy of a DataFrame or Series through chained assignment using an inplace method.
The behavior will change in pandas 3.0. This inplace method will never work because the intermediate object on which we are setting values always behaves as a copy.

For example, when doing 'df[col].method(value, inplace=True)', try using 'df.method({col: value}, inplace=True)' or df[col] = df[col].method(value) instead, to perform the operation inplace on the original object.


  df[column].replace("", np.nan, inplace=True)


Extracting data from source ...  took 0.3 seconds
Skipping re-process of ExporterSpecialCases
Extracting data from source ...  took 0.2 seconds
Skipping re-process of Production


/Users/jailsonsoares/repos/TRASE/trase/tools/etl/pandas_wrapper.py:162: FutureWarning: A value is trying to be set on a copy of a DataFrame or Series through chained assignment using an inplace method.
The behavior will change in pandas 3.0. This inplace method will never work because the intermediate object on which we are setting values always behaves as a copy.

For example, when doing 'df[col].method(value, inplace=True)', try using 'df.method({col: value}, inplace=True)' or df[col] = df[col].method(value) instead, to perform the operation inplace on the original object.


  df[column].replace("", np.nan, inplace=True)


Extracting data from source ...  took 0.3 seconds
Skipping re-process of MdicPort


/Users/jailsonsoares/repos/TRASE/trase/tools/etl/pandas_wrapper.py:162: FutureWarning: A value is trying to be set on a copy of a DataFrame or Series through chained assignment using an inplace method.
The behavior will change in pandas 3.0. This inplace method will never work because the intermediate object on which we are setting values always behaves as a copy.

For example, when doing 'df[col].method(value, inplace=True)', try using 'df.method({col: value}, inplace=True)' or df[col] = df[col].method(value) instead, to perform the operation inplace on the original object.


  df[column].replace("", np.nan, inplace=True)


Extracting data from source ...  took 0.3 seconds
Skipping re-process of Cost


/Users/jailsonsoares/repos/TRASE/trase/tools/etl/pandas_wrapper.py:162: FutureWarning: A value is trying to be set on a copy of a DataFrame or Series through chained assignment using an inplace method.
The behavior will change in pandas 3.0. This inplace method will never work because the intermediate object on which we are setting values always behaves as a copy.

For example, when doing 'df[col].method(value, inplace=True)', try using 'df.method({col: value}, inplace=True)' or df[col] = df[col].method(value) instead, to perform the operation inplace on the original object.


  df[column].replace("", np.nan, inplace=True)


Extracting data from source ...  took 0.3 seconds
Skipping re-process of Silos
Extracting data from source ...  took 0.3 seconds
Skipping re-process of IndustrialCapacity
Extracting data from source ...

/Users/jailsonsoares/repos/TRASE/trase/tools/etl/pandas_wrapper.py:162: FutureWarning: A value is trying to be set on a copy of a DataFrame or Series through chained assignment using an inplace method.
The behavior will change in pandas 3.0. This inplace method will never work because the intermediate object on which we are setting values always behaves as a copy.

For example, when doing 'df[col].method(value, inplace=True)', try using 'df.method({col: value}, inplace=True)' or df[col] = df[col].method(value) instead, to perform the operation inplace on the original object.


  df[column].replace("", np.nan, inplace=True)


     took 0.3 seconds
Skipping re-process of Sicasq
Extracting data from source ...  took 0.3 seconds
Skipping re-process of Fob
Extracting data from source ...

/Users/jailsonsoares/repos/TRASE/trase/tools/etl/pandas_wrapper.py:162: FutureWarning: A value is trying to be set on a copy of a DataFrame or Series through chained assignment using an inplace method.
The behavior will change in pandas 3.0. This inplace method will never work because the intermediate object on which we are setting values always behaves as a copy.

For example, when doing 'df[col].method(value, inplace=True)', try using 'df.method({col: value}, inplace=True)' or df[col] = df[col].method(value) instead, to perform the operation inplace on the original object.


  df[column].replace("", np.nan, inplace=True)


     took 0.3 seconds
Skipping re-process of NonMaritimeFlows


/Users/jailsonsoares/repos/TRASE/trase/tools/etl/pandas_wrapper.py:162: FutureWarning: A value is trying to be set on a copy of a DataFrame or Series through chained assignment using an inplace method.
The behavior will change in pandas 3.0. This inplace method will never work because the intermediate object on which we are setting values always behaves as a copy.

For example, when doing 'df[col].method(value, inplace=True)', try using 'df.method({col: value}, inplace=True)' or df[col] = df[col].method(value) instead, to perform the operation inplace on the original object.


  df[column].replace("", np.nan, inplace=True)
/Users/jailsonsoares/repos/TRASE/trase/tools/etl/pandas_wrapper.py:162: FutureWarning: A value is trying to be set on a copy of a DataFrame or Series through chained assignment using an inplace method.
The behavior will change in pandas 3.0. This inplace method will never work because the intermediate object on which we are setting values always behaves as a copy.

For example, when doing 'df[col].method(value, inplace=True)', try using 'df.method({col: value}, inplace=True)' or df[col] = df[col].method(value) instead, to perform the operation inplace on the original object.


  df[column].replace("", np.nan, inplace=True)
/Users/jailsonsoares/repos/TRASE/trase/tools/etl/pandas_wrapper.py:162: FutureWarning: A value is trying to be set on a copy of a DataFrame or Series through chained assignment using an inplace method.
The behavior will change in pandas 3.0. This inplace method will never work because the intermediate object on which we are setting values always behaves as a copy.

For example, when doing 'df[col].method(value, inplace=True)', try using 'df.method({col: value}, inplace=True)' or df[col] = df[col].method(value) instead, to perform the operation inplace on the original object.


  df[column].replace("", np.nan, inplace=True)


Extracting data from source ...  took 0.3 seconds
Skipping re-process of NewFlows
Running pre-processing for EmptyCnpj2019
Report: Before processing
        | Row Count: 0
Report: After processing
        | Row Count: 0
Written /Users/jailsonsoares/repos/TRASE/trase/models/brazil/soy/2022/prepared/full_cnpj_2019.csv
Running pre-processing for PortExporterTaxIdLHStickiness
Report: Before processing
        | Row Count: 0


/Users/jailsonsoares/repos/TRASE/trase/tools/etl/pandas_wrapper.py:162: FutureWarning: A value is trying to be set on a copy of a DataFrame or Series through chained assignment using an inplace method.
The behavior will change in pandas 3.0. This inplace method will never work because the intermediate object on which we are setting values always behaves as a copy.

For example, when doing 'df[col].method(value, inplace=True)', try using 'df.method({col: value}, inplace=True)' or df[col] = df[col].method(value) instead, to perform the operation inplace on the original object.


  df[column].replace("", np.nan, inplace=True)
/Users/jailsonsoares/repos/TRASE/trase/tools/etl/pandas_wrapper.py:162: FutureWarning: A value is trying to be set on a copy of a DataFrame or Series through chained assignment using an inplace method.
The behavior will change in pandas 3.0. This inplace method will never work because the intermediate object on which we are setting values always behaves as a copy.

For example, when doing 'df[col].method(value, inplace=True)', try using 'df.method({col: value}, inplace=True)' or df[col] = df[col].method(value) instead, to perform the operation inplace on the original object.


  df[column].replace("", np.nan, inplace=True)
/Users/jailsonsoares/repos/TRASE/trase/tools/etl/pandas_wrapper.py:162: FutureWarning: A value is trying to be set on a copy of a DataFrame or Series through chained assignment using an inplace method.
The behavior will change in pandas 3.0. This inplace method will never work because the intermediate object on which we are setting values always behaves as a copy.

For example, when doing 'df[col].method(value, inplace=True)', try using 'df.method({col: value}, inplace=True)' or df[col] = df[col].method(value) instead, to perform the operation inplace on the original object.


  df[column].replace("", np.nan, inplace=True)
/Users/jailsonsoares/repos/TRASE/trase/tools/etl/pandas_wrapper.py:162: FutureWarning: A value is trying to be set on a copy of a DataFrame or Series through chained assignment using an inplace method.
The behavior will change in pandas 3.0. This inplace method will never work because the intermediate object on which we are setting values always behaves as a copy.

For example, when doing 'df[col].method(value, inplace=True)', try using 'df.method({col: value}, inplace=True)' or df[col] = df[col].method(value) instead, to perform the operation inplace on the original object.


  df[column].replace("", np.nan, inplace=True)


Fetching 312 unique_labels from the database
Report: After processing
        | Row Count: 2,121
Written /Users/jailsonsoares/repos/TRASE/trase/models/brazil/soy/2022/prepared/port_exporter_tax_id_lh_stickiness.csv
Running pre-processing for PortExporterLHStickiness
Report: Before processing
        | Row Count: 0


/Users/jailsonsoares/repos/TRASE/trase/tools/etl/pandas_wrapper.py:162: FutureWarning: A value is trying to be set on a copy of a DataFrame or Series through chained assignment using an inplace method.
The behavior will change in pandas 3.0. This inplace method will never work because the intermediate object on which we are setting values always behaves as a copy.

For example, when doing 'df[col].method(value, inplace=True)', try using 'df.method({col: value}, inplace=True)' or df[col] = df[col].method(value) instead, to perform the operation inplace on the original object.


  df[column].replace("", np.nan, inplace=True)
/Users/jailsonsoares/repos/TRASE/trase/tools/etl/pandas_wrapper.py:162: FutureWarning: A value is trying to be set on a copy of a DataFrame or Series through chained assignment using an inplace method.
The behavior will change in pandas 3.0. This inplace method will never work because the intermediate object on which we are setting values always behaves as a copy.

For example, when doing 'df[col].method(value, inplace=True)', try using 'df.method({col: value}, inplace=True)' or df[col] = df[col].method(value) instead, to perform the operation inplace on the original object.


  df[column].replace("", np.nan, inplace=True)


Fetching 312 unique_labels from the database
Report: After processing
        | Row Count: 1,897
Written /Users/jailsonsoares/repos/TRASE/trase/models/brazil/soy/2022/prepared/port_exporter_lh_stickiness.csv
Running pre-processing for PortExporterStickiness
Report: Before processing
        | Row Count: 0


/Users/jailsonsoares/repos/TRASE/trase/tools/etl/pandas_wrapper.py:162: FutureWarning: A value is trying to be set on a copy of a DataFrame or Series through chained assignment using an inplace method.
The behavior will change in pandas 3.0. This inplace method will never work because the intermediate object on which we are setting values always behaves as a copy.

For example, when doing 'df[col].method(value, inplace=True)', try using 'df.method({col: value}, inplace=True)' or df[col] = df[col].method(value) instead, to perform the operation inplace on the original object.


  df[column].replace("", np.nan, inplace=True)
/Users/jailsonsoares/repos/TRASE/trase/tools/etl/pandas_wrapper.py:162: FutureWarning: A value is trying to be set on a copy of a DataFrame or Series through chained assignment using an inplace method.
The behavior will change in pandas 3.0. This inplace method will never work because the intermediate object on which we are setting values always behaves as a copy.

For example, when doing 'df[col].method(value, inplace=True)', try using 'df.method({col: value}, inplace=True)' or df[col] = df[col].method(value) instead, to perform the operation inplace on the original object.


  df[column].replace("", np.nan, inplace=True)


Fetching 312 unique_labels from the database
Report: After processing
        | Row Count: 807
Written /Users/jailsonsoares/repos/TRASE/trase/models/brazil/soy/2022/prepared/port_exporter_stickiness.csv
Running pre-processing for CnpjDb
Report: Before processing
        | Row Count: 0


/Users/jailsonsoares/repos/TRASE/trase/tools/etl/pandas_wrapper.py:162: FutureWarning: A value is trying to be set on a copy of a DataFrame or Series through chained assignment using an inplace method.
The behavior will change in pandas 3.0. This inplace method will never work because the intermediate object on which we are setting values always behaves as a copy.

For example, when doing 'df[col].method(value, inplace=True)', try using 'df.method({col: value}, inplace=True)' or df[col] = df[col].method(value) instead, to perform the operation inplace on the original object.


  df[column].replace("", np.nan, inplace=True)
/Users/jailsonsoares/repos/TRASE/trase/tools/etl/pandas_wrapper.py:162: FutureWarning: A value is trying to be set on a copy of a DataFrame or Series through chained assignment using an inplace method.
The behavior will change in pandas 3.0. This inplace method will never work because the intermediate object on which we are setting values always behaves as a copy.

For example, when doing 'df[col].method(value, inplace=True)', try using 'df.method({col: value}, inplace=True)' or df[col] = df[col].method(value) instead, to perform the operation inplace on the original object.


  df[column].replace("", np.nan, inplace=True)


Report: Add extra CNPJs
        | Row Count: 1,054
Report: After processing
        | Row Count: 1,038
Written /Users/jailsonsoares/repos/TRASE/trase/models/brazil/soy/2022/prepared/cnpj.csv


/Users/jailsonsoares/repos/TRASE/trase/tools/etl/pandas_wrapper.py:162: FutureWarning: A value is trying to be set on a copy of a DataFrame or Series through chained assignment using an inplace method.
The behavior will change in pandas 3.0. This inplace method will never work because the intermediate object on which we are setting values always behaves as a copy.

For example, when doing 'df[col].method(value, inplace=True)', try using 'df.method({col: value}, inplace=True)' or df[col] = df[col].method(value) instead, to perform the operation inplace on the original object.


  df[column].replace("", np.nan, inplace=True)


Failed 2022: cannot import name 'get_solver' from 'pulp' (/Users/jailsonsoares/repos/TRASE/.venv/lib/python3.11/site-packages/pulp/__init__.py)