Skip to content

build_data_evol_emploi

build_data_evol_emploi(data_source: DataFrame, col_new_ct: str, col_evol: str, y0_elasticite: float, seuil_pallier_elasticite_smic: float, pallier_elasticite: float, name_elasticite: str, keep_elast: bool, to_concat: bool, col_ct='salaire_super_brut')

Creates variables of interest concerning the employment effects of reforms.

Parameters:

Name Type Description Default
data_source DataFrame

The source data.

required
col_new_ct str

The column of the new cost of labor.

required
col_evol str

The column of the evolution.

required
y0_elasticite float

The initial value of the elasticity.

required
seuil_pallier_elasticite_smic float

The threshold of the elasticity in SMIC.

required
pallier_elasticite float

The step of the elasticity.

required
name_elasticite str

The name of the elasticity.

required
keep_elast bool

Whether to keep the elasticity.

required
to_concat bool

Whether to concatenate the result to the source data.

required
col_ct str

The column of the cost of labor. Defaults to 'salaire_super_brut'.

'salaire_super_brut'

Returns:

Type Description
DataFrame

The data with the employment effects variables.

Source code in bozio_wasmer_simulations/description/datasets.py
def build_data_evol_emploi(
    data_source: pd.DataFrame,
    col_new_ct: str,
    col_evol: str,
    y0_elasticite: float,
    seuil_pallier_elasticite_smic: float,
    pallier_elasticite: float,
    name_elasticite: str,
    keep_elast: bool,
    to_concat: bool,
    col_ct="salaire_super_brut",
):
    """
    Creates variables of interest concerning the employment effects of reforms.

    Args:
        data_source (pd.DataFrame): The source data.
        col_new_ct (str): The column of the new cost of labor.
        col_evol (str): The column of the evolution.
        y0_elasticite (float): The initial value of the elasticity.
        seuil_pallier_elasticite_smic (float): The threshold of the elasticity in SMIC.
        pallier_elasticite (float): The step of the elasticity.
        name_elasticite (str): The name of the elasticity.
        keep_elast (bool): Whether to keep the elasticity.
        to_concat (bool): Whether to concatenate the result to the source data.
        col_ct (str, optional): The column of the cost of labor. Defaults to 'salaire_super_brut'.

    Returns:
        (pd.DataFrame): The data with the employment effects variables.
    """
    # Copie indépendante du jeu de données
    data_emploi = data_source[
        ["salaire_brut_smic", "quotite_de_travail", col_evol]
    ].copy()

    # Création du suffixe
    suffix = col_new_ct[(col_new_ct.find(col_ct) + len(col_ct) + 1) :]
    # Calcul de l'élasticité emploi (en nombre d'EQTP) selon la méthode suivante
    # y0_elasticite au niveau du smic, pallier_elasticite à partir de seuil_pallier_elasticite_smic smic et on tire une droite entre les deux
    data_emploi[f"elast_{name_elasticite}"] = np.maximum(
        y0_elasticite,
        np.where(
            data_emploi["salaire_brut_smic"] < seuil_pallier_elasticite_smic,
            (
                y0_elasticite
                + (pallier_elasticite - y0_elasticite)
                / (seuil_pallier_elasticite_smic - 1)
                * (data_emploi["salaire_brut_smic"] - 1)
            ),
            pallier_elasticite,
        ),
    )

    # Ajout de l'effet emploi
    data_emploi[f"effet_emploi_{name_elasticite}_{suffix}"] = (
        data_emploi["quotite_de_travail"]
        * data_emploi[f"elast_{name_elasticite}"]
        * data_emploi[col_evol]
    )

    # Déduction de la quotité de travail associée
    data_emploi[f"quotite_de_travail_{name_elasticite}_{suffix}"] = (
        data_emploi["quotite_de_travail"]
        + data_emploi[f"effet_emploi_{name_elasticite}_{suffix}"]
    )

    if to_concat:
        # Concaténation
        if not keep_elast:
            data_source = pd.concat(
                [
                    data_source,
                    data_emploi.drop(
                        [
                            "salaire_brut_smic",
                            "quotite_de_travail",
                            f"elast_{name_elasticite}",
                            col_evol,
                        ],
                        axis=1,
                    ),
                ],
                axis=1,
                join="outer",
            )
        else:
            data_source = pd.concat(
                [
                    data_source,
                    data_emploi.drop(
                        ["salaire_brut_smic", "quotite_de_travail", col_evol], axis=1
                    ),
                ],
                axis=1,
                join="outer",
            )
        # Suppression du jeu de données des emplois
        del data_emploi
        return data_source
    else:
        return data_emploi