Skip to main content

OpenFisca-France-Data module to work with French survey data

Project description

OpenFisca France Data

Newsletter Twitter Slack Coveralls Python PyPi

[EN] Introduction

OpenFisca is a versatile microsimulation free software. You can check the online documentation for more details.

This repository contains the OpenFisca-France-Data module, to work with OpenFisca-France and French survey or population data (ERFS and ERFS-FPR).

Here is the list of the managed data:

  • DADS, annual declaration of social data ;
  • ERFS, tax and social incomes survey ;
  • ERFS-FPR, ERFS production and research files ;
  • FELIN, sampled file of the income tax.

To transform your survey data into OpenFisca-France-Data formatted data you need to start with openfisca-survey-manager repository.

[FR] Introduction

OpenFisca est un logiciel libre de micro-simulation. Pour plus d'information, vous pouvez consulter la documentation officielle.

Ce dépôt contient le module OpenFisca-France-Data. Il permet d'associer l'usage d'OpenFisca-France à des données d'enquête ou de population sur la France.

Ceci est la liste les données traitées :

  • DADS, Déclaration Annuelle des Données Sociales ;
  • ERFS, Enquête Revenus Fiscaux et Sociaux ;
  • ERFS-FPR, ERFS fichiers de Production et de Recherche ;
  • FELIN, fichier échantillonné de l'impôt sur le revenu.

Afin de transformer vos données d'enquête en des données au format OpenFisca-France-Data, vous aurez à débuter par le dépôt openfisca-survey-manager.

Environment

OpenFisca-France-Data runs on Python from version 3.7. More recent versions should work, but are not tested.

Backward compatibility with Python 2.7 has been dropped since January 1st, 2019.

Installation

Installing with conda

Since version 0.22.0, you could use conda to install OpenFisca-France-Data.

Conda is the easiest way to use OpenFisca under Windows as by installing Anaconda you will get:

If you are familiar with the command line you could use Miniconda, which needs very much less disk space than Anaconda.

After installing conda, run these commands in an Anaconda Powershell Prompt:

  • conda create --name openfisca python=3.9 to create an openfisca environment.
  • conda activate openfisca to use your new environment.

Then, choose one of the following options according to your use case:

  • conda install -c conda-forge -c openfisca openfisca-france-data for default dependencies,
  • or conda install -c conda-forge -c openfisca openfisca-france-data-test if you want all the dependencies needed to contribute to the project.

For information on how we publish to conda, see .conda/README.md.

Development installation

You can follow this installation if you want to:

  • run one of OpenFisca-France-Data scripts,
  • develop and contribute to OpenFisca-France-Data source code. Please be welcomed! :)

You will need to download and install the module locally:

git clone https://github.com/openfisca/openfisca-france-data.git
cd openfisca-france-data
make install

This should not display any error and end with:

Successfully installed OpenFisca-France-Data...

Specifics due to Windows' handling of long paths

On a Windows machine, the installation of Openfisca-France-Data may run into problems due to long path names, which Windows, by default, does not handle. These long paths are mostly inherited from the OpenFisca-France parameters, which are stored in a sometimes deeply nested folder.

A possible workaround on Windows >= 10 is to lift the maximum path length limitation (as indicated here).

Execution

Let's say that you would like to format ERFS-FPR survey data into OpenFisca formatted data.

💡If you have other data managed by openfisca-france-data (like FELIN), change erfs_fpr by your data name in the next steps description.

You have already used openfisca-survey-manager. So, you have a config.ini file configured for this survey and a HDF5 file generated in the directory that you defined under output_directory in your config.ini.

For more information, you can see the configuration steps of openfisca-survey-manager README.

To run openfisca_france_data on ERFS-FPR survey data:

  1. Run the command:

    build-erfs-fpr -y 2013 -f dummy_data.h5
    

    You can change 2013 with any year you are interested in and for which you have ERFS-FPR data and dummy_data.h5 with any filename you want to export a flatenned dataframe.

    The script should end without error and display these lines:

    INFO:__main__:Script finished after...
    Closing remaining open files...
    
  2. Check the script results:

    • openfisca_erfs_fpr.json file generated in the directory you configured in your config.ini under collections_directory key.
    • input.h5 file generated in the directory you configured in your config.ini under output_directory key. This HDF5 file contains a group with two items:
      • an item with your data organised by OpenFisca-France Individu entity,
      • an item with your data organised by OpenFisca-France Menage entity.
    • Specific to ERFS-FPR script: dummy_data.h5 if you kept export_flattened_df_filepath option's value.

    The script also adds a openfisca_erfs_fpr key to your config.ini.

Testing

To run the entire test suite:

make test

Style

This repository adheres to a certain coding style, and we invite you to follow it for your contributions to be integrated promptly.

To run the style checker:

make check-style

To automatically style-format your code changes:

make format-style

To automatically style-format your code changes each time you commit:

touch .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit

tee -a .git/hooks/pre-commit << END
#!/bin/sh
#
# Automatically format your code before committing.
exec make format-style
END

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

OpenFisca-France-Data-3.1.2.tar.gz (167.1 kB view details)

Uploaded Source

Built Distribution

OpenFisca_France_Data-3.1.2-py3-none-any.whl (195.8 kB view details)

Uploaded Python 3

File details

Details for the file OpenFisca-France-Data-3.1.2.tar.gz.

File metadata

  • Download URL: OpenFisca-France-Data-3.1.2.tar.gz
  • Upload date:
  • Size: 167.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.9

File hashes

Hashes for OpenFisca-France-Data-3.1.2.tar.gz
Algorithm Hash digest
SHA256 748d27b56fe19d9e32d8e5aaaba7db46d43524d89649b25c70c27b8dce93e836
MD5 41e08fd21b4a6b0ddf8231c66e7a945f
BLAKE2b-256 e5a0e7827a78e7dde8c0839b4c4903bd15987123d1f13b24b9a9607c87337521

See more details on using hashes here.

File details

Details for the file OpenFisca_France_Data-3.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for OpenFisca_France_Data-3.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b8353fa0601f033e618c0034fdb7f29cfcb70f8592ba277980ef3fcf3e877d59
MD5 82fc856c60f53154c125618916d99b13
BLAKE2b-256 fe595431727306c30d307f735382fe528802befb9dafe6d5979dce3e23d8d899

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page