Exemple #1
0
def get_common_dataframe(variables, year=2006):
    """
    Compare variables in erf an openfisca
    """
    simulation = SurveySimulation()
    simulation.set_config(year=year)
    simulation.set_param()
    simulation.set_survey()
    simulation.compute()

    erf = ErfsDataTable(year=2006)
    if "ident" not in variables:
        erf_variables = variables + ["ident"]
    else:
        erf_variables = variables

    if "wprm" not in erf_variables:
        erf_variables = erf_variables + ["wprm"]
    else:
        erf_variables = erf_variables

    erf_dataframe = erf.get_values(erf_variables, table="menage")
    erf_dataframe.rename(columns={'ident': 'idmen'}, inplace=True)
    for col in erf_dataframe.columns:
        if col is not "idmen":
            erf_dataframe.rename(columns={col: col + "_erf"}, inplace=True)

    of_dataframe, of_dataframe_default = simulation.aggregated_by_entity(
        "men", variables, all_output_vars=False, force_sum=True)
    del of_dataframe_default

    merged_df = of_dataframe.merge(erf_dataframe, on="idmen")
    del of_dataframe, erf_dataframe
    return merged_df
Exemple #2
0
def get_menage(idmen):
    erf = ErfsDataTable(year=2006)
    erf_variables = ["ident", "age", "noi", "persfip", "persfipd","quelfic", "declar1", "declar2"]
    dataframe = erf.get_values(erf_variables, table="indivi")
    dataframe.rename(columns={'ident': 'idmen'}, inplace=True)
    selection = dataframe.idmen == idmen
    return dataframe[selection]
Exemple #3
0
def get_common_dataframe(variables, year = 2006):
    """
    Compare variables in erf an openfisca
    """
    simulation = SurveySimulation()
    simulation.set_config(year = year)
    simulation.set_param()
    simulation.set_survey()
    simulation.compute()

    erf = ErfsDataTable(year=2006)
    if "ident" not in variables:
        erf_variables = variables + ["ident"]
    else:
        erf_variables = variables

    if "wprm" not in erf_variables:
        erf_variables = erf_variables + ["wprm"]
    else:
        erf_variables = erf_variables

    erf_dataframe = erf.get_values(erf_variables, table="menage")
    erf_dataframe.rename(columns={'ident': 'idmen'}, inplace=True)
    for col in erf_dataframe.columns:
        if col is not "idmen":
            erf_dataframe.rename(columns={col: col + "_erf"}, inplace=True)

    of_dataframe, of_dataframe_default = simulation.aggregated_by_entity("men", variables, all_output_vars=False, force_sum=True)
    del of_dataframe_default

    merged_df = of_dataframe.merge(erf_dataframe, on="idmen")
    del of_dataframe, erf_dataframe
    return merged_df
Exemple #4
0
def get_menage(idmen):
    erf = ErfsDataTable(year=2006)
    erf_variables = [
        "ident", "age", "noi", "persfip", "persfipd", "quelfic", "declar1",
        "declar2"
    ]
    dataframe = erf.get_values(erf_variables, table="indivi")
    dataframe.rename(columns={'ident': 'idmen'}, inplace=True)
    selection = dataframe.idmen == idmen
    return dataframe[selection]
# This file is part of OpenFisca.
# OpenFisca is a socio-fiscal microsimulation software
# Copyright © #2013 Clément Schaff, Mahdi Ben Jelloul
# Licensed under the terms of the GVPLv3 or later license
# (see openfisca/__init__.py for details)


from numpy import arange
from openfisca_core.statshelpers import mark_weighted_percentiles
from openfisca_france.data.erf.datatable import ErfsDataTable
from openfisca_france.data.sources.config import destination_dir
from pandas import DataFrame, ExcelWriter


year = 2009
erf = ErfsDataTable(year=year)
#erf.set_config()
vars = [ "zrstm", "zchom", "pfamm", "wprm", "pauvre50m", "pauvre60m", "nivviem", "champm"]
df = erf.get_values(variables=vars, table="erf_menage" )


labels = arange(1,11)
method = 2

nivvie = df["nivviem"].astype("float64").values

wprm = df["wprm"].astype("float64").values
decil, values = mark_weighted_percentiles(nivvie, labels, wprm, method, return_quantiles = True)


df2 = DataFrame({"decile" : decil})