Using the Python API

Using the Python API

(Rules as Code + OpenFisca) training series, session five.

OpenFisca Python API

Allows for large scale simulations

Useful for modelling and large datasets

Documentation:
http://openfisca.org/doc/openfisca-python-api/index.html

Simulations

"OpenFisca works the same if there is one person, seven, or seven million in the modelled situation."

Leverages Vector computing via the NumPy package

Trace feature allows for analysis of simulation results

Test case simulations

Matches the Web API functionality

Test cases can be written in Python

Requires the SimulationBuilder and a CountryTaxBenefitSystem

from openfisca_core.simulation_builder import SimulationBuilder from openfisca_country_template import CountryTaxBenefitSystem

Bulk data simulations

Data can come from database, csv file etc.

At a minimum a simulation requires:

  • unique ids for persons and group entities
  • applicable variable names from the CountryTaxBenefitSystem
  • the period and entity for each set of values

Advanced simulations

Explore the OpenFisca documentation for topics like:

OpenFisca Python API Documentation

Extensive documentation can be found on the OpenFisca documentation site


Hotkeys

  • f: full screen

  • s: speaker notes

  • b: pause

  • / / space: navigate through slides

  • cltr / alt + click to zoom