Multifunctional Analysis of Regions through Input-Output

Related tags

MiscellaneousMARIO
Overview
https://img.shields.io/gitter/room/SESAM-Polimi/MARIO Documentation Status https://img.shields.io/pypi/v/mariopy https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png

MARIO

Multifunctional Analysis of Regions through Input-Output. (Documents)

What is it

MARIO is a python package for handling input-output tables and models inspired by pymrio. MARIO aims to provide a simple & intuitive API for common IO tasks without needing in-depth programming knowledge. MARIO supporst automatic parsing of different structured tables such EXIOBASE, EORA, EUROSTAT in different formats namely:

  • Single region
  • Multi region
  • Hybrid tables
  • Monetary tables
  • Input-Output tables
  • Supply-Use tables

When databases are not structured, MARIO supports parsing data from xlsx, csv, txt files or pandas.DataFrames.

More than parsing data, MARIO includes some basic functionalities:

  • Aggregation of databases
  • SUT to IOT transformation
  • Modifying database in terms of adding:
    • New sectors, activities or commodities to the database
    • Adding new extensions to the satellite account
  • Scneario and shock analysis
  • Backward and forward linkages analysis
  • Extracting single region database from multi region databases
  • Balance test
  • Productivity test
  • Exporting the databases into different formats for scenarios analyzed
  • Interactive visualization routines

Requirements

MARIO has been tested on macOS and Windows.

To run MARIO, a couple of things are needed:

  1. Being in love with Input-Output :-)
  2. The Python programming language, version 3.7 or higher
  3. A number of Python adds-on packages
  4. For some functionalities a solver may needed (optional)
  5. MARIO software itself

Recommended installation method

The easiest way to make MARIO software working is to use the free conda package manager which can install the current and future MARIO depencies in an easy and user friendly way.

To get conda, download and install "Anaconda Distribution" . Between differnet options for running python codes, we strongly suggest, Spyder, which is a free and open source scientific environment written in Python, for Python, and designed by and for scientists, engineers and data analysts.

You can install mario using pip or from source code. It is suggested to create a new environment by running the following command in the anaconda prompt

conda create -n mario python=3.8

If you create a new environment for mario, to use it, you need to activate the mario environment each time by writing the following line in Anaconda Prompt

conda activate mario

Now you can use pip to install mario on your environment as follow:

pip install mariopy

You can also install from the source code!

Quickstart

A simple test for Input-Output Table (IOT) and Supply-Use Table (SUT) is included in mario.

To use the IOT test, call

import mario
test_iot = mario.load_test('IOT')

and to use the SUT test, call

test_sut = mario.load_test('SUT')

To see the configurations of the data, you can print them:

print(test_iot)
print(test_sut)

To see specific sets of the tables like regions or value added, get_index function can be used:

print(test_iot.get_index('Region'))
print(test_sut.get_index('Factor of production'))

To visualize some data, various plot functions can be used:

test_iot.plot_matrix(....)

Specific modifications on the database can be done, such as SUT to IOT transformation:

reformed_iot = test.sut_to_iot(method='B')

The changes can be tracked by metadata. The history can be checked by calling:

reformed_iot.meta_history

The new database can be saved into excel,txt or csv file:

reformed_iot.to_excel(path='a folder//database.xlsx')

Python module requirements

Some of the key packages the mario relies on are:

Note

  • This project is under active development.
  • More examples will be uploaded through time to the gellery.
  • More parsers will be added to the next version.
  • The next version will cover some optimization models within the IO framework

License

https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png

This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)

Comments
  • Misleading error message for `parse_eurostat`

    Misleading error message for `parse_eurostat`

    Following the documentation for the Eurostat-parsing functionality, I ran into below error ("non-corresponding years"). This is unexpected since I was strictly following the documentation, i.e. did everything as described there. Any ideas why that happens and how to get my SUTs?

    `--------------------------------------------------------------------------- WrongInput Traceback (most recent call last) c:\Users\maximiko\IO-testbed\Eurostat_MARIO.py in ----> 18 italy_sut = parse_eurostat( 19 supply_path = supply_path, 20 use_path = use_path, 21 region = "Italy", 22 year = 2011

    ~\Anaconda3\envs\pymrio\lib\site-packages\mario\tools\parsersclass.py in parse_eurostat(supply_path, use_path, region, year, consumption_categories, factors_of_production, imports, model, name, calc_all, **kwargs) 432 table = "SUT" 433 if table == "SUT": --> 434 matrices, indeces, units = eurostat_sut( 435 supply_path, 436 use_path,

    ~\Anaconda3\envs\pymrio\lib\site-packages\mario\tools\tableparser.py in eurostat_sut(supply_path, use_path, region, selected_year, consumption_categories, factors_of_production, imports) 992 years = supply_years 993 else: --> 994 raise WrongInput("No correspondance between years of use and supply tables") 995 996 "Warning on supply in IxP format, Use in PxI format"

    WrongInput: No correspondance between years of use and supply tables`

    enhancement 
    opened by maximikos 4
  • New parse hybrid Exiobase from Zenodo

    New parse hybrid Exiobase from Zenodo

    Now the Hybrid version of EXIOBASE is available on Zenodo at https://zenodo.org/record/7244919#.Y6Lr0NXMIQ8

    A new parse function is needed in order to take advantage of a lighter format.

    enhancement 
    opened by nigolred 1
  • calc all keyerror management

    calc all keyerror management

    In the calc_all function, we should check at the beginning of the function whether the scenario exists or not so the keyerror won't be about the missing scenario.

    opened by LorenzoRinaldi 1
  • search function minor improvement

    search function minor improvement

    The search function should not be case sensitive. For instance, if the user run this command:

    db.search("Sector","electricity")

    he will not be able to track for sectors named "Electricity..." with capital "E". It would be super-useful to improve this making the function not case-sensitive

    opened by LorenzoRinaldi 1
  • Pymrio integration

    Pymrio integration

    pull request for merging the functions and methods added for mario vs pymrio integration.

    Changes:

    • Adding a new method for converting mario.Database to pymrio.IOSystem in Database class
    • Adding the parser function to parsers that reshapes the pymrio.IOSystem and pymrio.Extensions to mario.Database
    • miscellaneous changes in tools and constants to map the differences in two libraries
    opened by mohammadamint 1
  • There should be a way to store the metadata that generated a new database

    There should be a way to store the metadata that generated a new database

    Every time a new database is printed-out there should be a way to access information on the:

    • year
    • table version
    • added extensions
    • ...

    Printing out the metadata (as a txt file in case .to_txt or .to_csv is used; as an additional sheet in case .to_excel is used) can do the job

    opened by nigolred 1
  • Add a Gitter chat badge to README.rst

    Add a Gitter chat badge to README.rst

    SESAM-Polimi/MARIO now has a Chat Room on Gitter

    @LorenzoRinaldi has just created a chat room. You can visit it here: https://gitter.im/SESAM-Polimi/MARIO.

    This pull-request adds this badge to your README.rst:

    Gitter

    If my aim is a little off, please let me know.

    Happy chatting.

    PS: Click here if you would prefer not to receive automatic pull-requests from Gitter in future.

    opened by gitter-badger 1
  • Add pymrio package to requirements

    Add pymrio package to requirements

    TLDR I tried to follow the Mario set up instruction and I believe the pymrio package is missing from requirements.txt. I am using this as an opportunity to try my first pull request on the MARIO repo just to make sure everything works properly.

    REPRO

    i tried to install MARIO and then run a simple script using it. Here is the script I tried: https://gist.github.com/AAmedeo/fdeb1f74413d109d3f2727fa1116e687

    This is what happened before adding pymrio to requirements.txt

    [email protected] MARIO % rm -r venv
    [email protected] MARIO % python3 -m venv venv
    [email protected] MARIO % source ./venv/bin/activate
    (venv) [email protected] MARIO % pip3 install -r requirements.txt
    (venv) [email protected] MARIO % python3 mario_hello_world.py
    Traceback (most recent call last):
      File "mario_hello_world.py", line 1, in <module>
        import mario
      File "/Users/afa/Desktop/MARIO/mario/__init__.py", line 48, in <module>
        from mario.core.AttrData import Database
      File "/Users/afa/Desktop/MARIO/mario/core/AttrData.py", line 91, in <module>
        from mario.core.CoreIO import CoreModel
      File "/Users/afa/Desktop/MARIO/mario/core/CoreIO.py", line 15, in <module>
        from mario.tools.tableparser import dataframe_parser
      File "/Users/afa/Desktop/MARIO/mario/tools/tableparser.py", line 48, in <module>
        import pymrio
    ModuleNotFoundError: No module named 'pymrio'
    

    This is what happened after adding pymrio to requirements.txt

    [email protected] MARIO % rm -r venv
    [email protected] MARIO % python3 -m venv venv
    [email protected] MARIO % source ./venv/bin/activate
    (venv) [email protected] MARIO % pip3 install -r requirements.txt
    (venv) [email protected] MARIO % python3 mario_hello_world.py
    cvxpy module is not installed in your system. This will raise problems in some of the abilities of MARIO
    name = IOT test
    table = IOT
    scenarios = ['baseline']
    Factor of production = 3
    Satellite account = 4
    Consumption category = 1
    Region = 2
    Sector = 6
    
    name = SUT test
    table = SUT
    scenarios = ['baseline']
    Activity = 6
    Commodity = 6
    Factor of production = 3
    Satellite account = 1
    Consumption category = 1
    Region = 2
    
    ['RoW', 'Italy']
    ['Taxes', 'Wages', 'Capital']
    
    opened by AAmedeo 0
  • Add sectors conflict with pandas 1.4.4. version

    Add sectors conflict with pandas 1.4.4. version

    Using add_sectors function with pandas version 1.4.4 lead to the following error:

    ValueError: Length of new names must be 1, got 3

    The function works with pandas 1.3.3

    dependencies 
    opened by LorenzoRinaldi 1
  • Adding parsing function for Exiobase 3.3.18 (hybrid) version

    Adding parsing function for Exiobase 3.3.18 (hybrid) version

    I am requesting to merge these changes to main branch. The changes implement a new parser function for exiobase database, in particular referring to version 3.3.18, downloadable at this link

    In particular, the new feature have been implemented by updating the already present function parse_exiobase_sut, by adding the unit, version and extensions attributes.

    The unit attribute can be selected among the _acceptable_units list, saved in the parserid.py file, and is by default set to "monetary". In the default case, the function is run exactly in the same way as the one in the main branch. The version attribute is by default set to None and must be provided in case unit="hybrid" The extensions attribute is by default set to None and can be provided as a list including any of the keys of the _acceptable_extensions dictionay saved in the parserid.py file.

    Regarding the case when unit="hybrid", then the new hybrid_sut_parser function (in tableparser.py) will be invoked (see commit 799443fd5b3e0944894238b0d4c5861fe8e18640).

    Initially, this function was developed to parse an old version of the database, downloadable from the official exiobase website, which was saved as a zip file. This version had supply, use and final demand matrices saved into separate .xlsb files therefore the parser was significantly slower than other ones for other exiobase versions. The function was then modified in order to parse the database as the one available on zenodo (link reported previously), where the same matrices are available by default in .csv formats (much faster to be read).

    Another improvement brought by this merge would be the fact that the aggregation excel file template obtained by the get_aggregation_excel function, automatically prints a new sheet showing the units of each entry of each set. This would ease the process of aggregation in case of hybrid databases.

    enhancement 
    opened by LorenzoRinaldi 0
  • Obsolete xlsxwriter dependency

    Obsolete xlsxwriter dependency

    I see the package depency states "xlsxwriter <= 1.3.7", whereas the current version is 3.0.3... Is this really required? When installing the package, it downgraded my package version, and broke functionnalities with other Python scripts I'm running. Thanks in advance...

    enhancement 
    opened by adrienjacob 1
  • Get_data function

    Get_data function

    The function "get_data" is not working if the user provide an integer as "scenarios" parameter. Not even if it is provided within a list. Moreover, the documentation for this function seems missing.

    bug documentation 
    opened by LorenzoRinaldi 0
  • Activity units

    Activity units

    Check if actvity units is making sense, in general: do they need to be provided with units? Especially in hybrid database the answer is probably no, while for economic databases it is the opposite.

    Also, hybrid database need for further checks when dealing with aggregation of activities due to the fact activities may produce commodities with different units

    opened by LorenzoRinaldi 0
Releases(v0.1.0)
Python Classes Without Boilerplate

attrs is the Python package that will bring back the joy of writing classes by relieving you from the drudgery of implementing object protocols (aka d

The attrs Cabal 4.6k Jan 02, 2023
Attempt at creating organized collection of little handy snippets of code I'm receiving along the way

ChaosCode Attempt at creating organized collection of little handy snippets of code I'm receiving along the way I always considered coding and program

INFU 4 Nov 26, 2022
Beatsaber for Python

beatsaber Beatsaber for Python It was automatically generated with mkpylib. If you're reading this message, it m

Shawn Presser 3 Jul 30, 2021
System Design Assignments as part of Arpit's System Design Masterclass

System Design Assignments The repository contains a set of problem statements around Software Architecture and System Design as conducted by Arpit's S

Relog 1.1k Jan 09, 2023
Interactivity Lab: Household Pulse Explorable

Interactivity Lab: Household Pulse Explorable Goal: Build an interactive application that incorporates fundamental Streamlit components to offer a cur

1 Feb 10, 2022
General tricks that may help you find bad, or noisy, labels in your dataset

doubtlab A lab for bad labels. Warning still in progress. This repository contains general tricks that may help you find bad, or noisy, labels in your

vincent d warmerdam 449 Dec 26, 2022
Decentralized intelligent voting application.

DiVA Decentralized intelligent voting application. Hack the North 2021. Inspiration Following the previous US election, many voters were fearful that

Ali Shariatmadari 4 Jun 05, 2022
A web application which you can search, buy or sell shares with current prices which provided by IEX.

CS50 - Stock Exchange A web application which you can search, buy or sell shares with current prices which provided by IEX. Table of Contents Setup St

1 May 28, 2022
Secret santa is a fun and easy way to get together with your friends and/or family with a gift for them.

Vaccine Validator Tool to validate domestic New Zealand vaccine passes Create a new virtual environment: python3 -m venv ./venv Activate virtual envi

2 Dec 06, 2021
Structured Exceptions for Python

XC: Structured exceptions for Python XC encourages a structured, disciplined approach to use of exceptions: it reduces the overhead of declaring excep

Bob Gautier 2 May 28, 2021
Keep your company's passwords behind the firewall

TeamVault TeamVault is an open-source web-based shared password manager for behind-the-firewall installation. It requires Python 3.3+ and Postgres (wi

//SEIBERT/MEDIA GmbH 38 Feb 20, 2022
A Python module for decorators, wrappers and monkey patching.

wrapt The aim of the wrapt module is to provide a transparent object proxy for Python, which can be used as the basis for the construction of function

Graham Dumpleton 1.8k Jan 06, 2023
Mangá downloader (para leitura offline) voltado para sites e scans brasileiros.

yonde! yonde! (読んで!) é um mangá downloader (para leitura offline) voltado para sites e scans brasileiros. Também permite que você converta os capítulo

Yonde 8 Nov 28, 2021
A domonic-like wrapper around selectolax

A domonic-like wrapper around selectolax

byteface 3 Jun 23, 2022
Synchrosqueezing, wavelet transforms, and time-frequency analysis in Python

Synchrosqueezing is a powerful reassignment method that focuses time-frequency representations, and allows extraction of instantaneous amplitudes and frequencies

John Muradeli 382 Jan 06, 2023
Simple logger for Urbit pier size, with systemd timer template

urbit-piermon Simple logger for Urbit pier size, with systemd timer template. Syntax piermon.py -i [PATH TO PIER] -o [PATH TO OUTPUT CSV] systemd serv

1 Nov 07, 2021
Datargsing is a data management and manipulation Python library

Datargsing What is It? Datargsing is a data management and manipulation Python library which is currently in deving Why this library is good? This Pyt

CHOSSY Lucas 10 Oct 24, 2022
Automation in socks label validation

This is a project for socks card label validation where the socks card is validated comparing with the correct socks card whose coordinates are stored in the database. When the test socks card is com

1 Jan 19, 2022
0xFalcon - 0xFalcon Tool For Python

0xFalcone Installation Install 0xFalcone Tool: apt install git git clone https:/

Alharb7 6 Sep 24, 2022
A fast python implementation of DTU MVS 2014 evaluation

DTUeval-python A python implementation of DTU MVS 2014 evaluation. It only takes 1min for each mesh evaluation. And the gap between the two implementa

82 Dec 27, 2022