API Reference
API references for all modules
Data input and output
Test system
Returns a small test MRIO |
Download MRIO databases
Download publicly EE MRIO databases from the web. This is currently implemented for the WIOD and OECD_ICIO database (EXIOBASE and EORA26 require registration before downloading).
|
Downloads EXIOBASE 3 files from Zenodo |
|
Downloads the 2013 wiod release |
|
Downloads the OECD ICIO tables |
Raw data
|
Parse the exiobase1 raw data files. |
|
Parse the exiobase 2.2.2 source files for the IOSystem |
|
Parses the public EXIOBASE 3 system |
|
Generic EXIOBASE version 1 and 2 parser |
|
Parse the wiod source files for the IOSystem |
|
Parse the Eora26 database |
|
Parse the OECD ICIO tables |
Save data
Currently, the full MRIO system can be saved in txt or the python specific binary format (‘pickle’). Both formats work with the same API interface:
|
Saving the system to path |
|
Saves the system and all extensions |
Already saved MRIO databases can be archived with
|
Archives a MRIO database as zip file |
Load processed data
This functions load IOSystems or individual extensions which have been saved with pymrio before.
|
Loads a IOSystem or Extension previously saved with pymrio |
|
Loads a full IO system with all extension in path |
Accessing
pymrio stores all tables as pandas DataFrames. This data can be accessed with the usual pandas methods. On top of that, the following functions return (in fact yield) several tables at once:
|
Yields all panda.DataFrames or there names |
|
Yields the extensions or their names |
For the extensions, it is also possible to receive all data (F, S, M, D_cba, …) for one specified row.
|
Returns a dict with all available data for a row in the extension. |
Exploring and Search
Structure
The following functions provide informations about the structure of the IO System and the extensions. The methods work on the IOSystem as well as directly on the Extensions.
|
Returns the names of regions in the IOSystem as unique names in order |
|
Names of sectors in the IOSystem as unique names in order |
|
Returns names of y cat. |
|
Returns the index of the DataFrames in the system |
|
Sets the pd dataframe index of all dataframes in the system to index |
Returns the gross bilateral trade flows and totals |
|
Returns the name of the rows of the extension |
Finding accounts
|
Looks for term in index, sectors, regions, Y_categories |
|
Check if index of the system contains the regex pattern |
|
Check if index of the system match the regex pattern |
|
Check if a index row of the system is a full match to the regex pattern |
|
Check if index of the system contains the regex pattern |
|
Check if index of the system match the regex pattern |
|
Check if a index row of the system is a full match to the regex pattern |
|
Get a dict of extension index dicts which contains a search pattern |
|
Get a dict of extension index dicts with full match of a search pattern. |
|
Get a dict of extension index dicts which match a search pattern |
|
Check if index contains a regex pattern. |
Calculations
Top level methods
The top level level function calc_all checks the IO System and its extensions for missing parts and calculate these. This function calls the specific calculation method for the core system and for the extensions.
Calculates missing parts of the IOSystem and all extensions. |
|
Calculates the missing part of the core IOSystem |
|
|
Calculates the missing part of the extension plus accounts |
Low level matrix calculations
The top level functions work by calling the following low level functions. These can also be used independently from the IO System for pandas DataFrames and numpy array.
|
Calculate the industry output x from the Z and Y matrix |
|
calculate the Z matrix (flows) from A and x |
|
Calculate the A matrix (coefficients) from Z and x |
|
Calculate the Leontief L from A |
|
Calculate extensions/factor inputs coefficients |
|
Calculate total direct impacts from the impact coefficients |
|
Calculate multipliers of the extensions |
|
Calculate total impacts (footprints of consumption Y) |
|
Calculate sector specific cba and pba based accounts, imp and exp accounts |
Metadata and history recording
Each pymrio core system object contains a field ‘meta’ which stores meta data as well as changes to the MRIO system. This data is stored as json file in the root of a saved MRIO data and accessible through the attribute ‘.meta’.
|
|
|
Add the passed string as note to the history |
All recorded history |
|
All modification history entries |
|
All note history entries |
|
All fileio history entries |
|
|
Saves the current status of the metadata |
Modifiying the IO System and its Extensions
Aggregation
The IO System method ‘aggregate’ accepts concordance matrices and/or aggregation vectors. The latter can be generated automatically for various aggregation levels for the test system and EXIOBASE 2.
|
Aggregates the IO system. |
|
Builds an combined aggregation vector considering diff classifications |
Characterizing stressors
|
Characterize stressors |
Analysing the source of impacts
|
Diagonalize one row of the stressor matrix for a flow analysis. |
Changing extensions
Remove extension from IOSystem |
|
|
Concatenate extensions |
|
Parse an EXIOBASE version 1 or 2 like extension file into pymrio.Extension |
Adjusting and Renaming
|
Sets new names for the regions |
|
Sets new names for the sectors |
|
Sets new names for the Y_categories |
Getting predefined Classifications of MRIOs
|
Get predefined classifications included in pymrio |
|
Classification data for MRIOs |
Report
The following method works on the IO System (generating reports for every extension available) or at individual extensions.
|
Generates a report to the given path for all extension |
Visualization
|
Plots D_pba, D_cba, D_imp and D_exp for the specified row (account) |
Utility
Routines developed for pymrio which can also be used independently.
|
Match regex on index of df_ix |
|
Check if index contains a regex pattern. |
|
Fullmatch regex on index of df_ix |
|
Aggregation based on mapping given in input as numerical or str vector. |
|
Builds an combined aggregation vector considering diff classifications |
|
Converts the pymrio matrix df format to a long format |
Miscellaneous
|
Keeps only the absolute values. |
Keeps only the coefficient. |
|
|
Returns a deep copy of the system |