Skip to content

load_fare

load_fare(project: str, year: int, columns: List[str], filters: Optional[List[Tuple[str, str, str]]] = None)

Loads the FARE data for a given year.

Parameters:

Name Type Description Default
project str)

The name of the CASD project

required
year int

The year of the data to load.

required
columns List[str]

The columns to load.

required
filters Optional[List[Tuple[str, str, str]]]

The filters to apply. Each filter is a tuple of (column, operator, value). Defaults to None.

None

Returns:

Type Description
DataFrame

The loaded data.

Source code in bozio_wasmer_simulations/datasets/loaders.py
def load_fare(
    project : str, year: int, columns: List[str], filters: Optional[List[Tuple[str, str, str]]] = None
):
    """
    Loads the FARE data for a given year.

    Args:
        project (str) : The name of the CASD project
        year (int): The year of the data to load.
        columns (List[str]): The columns to load.
        filters (Optional[List[Tuple[str, str, str]]], optional): The filters to apply. Each filter is a tuple of (column, operator, value). Defaults to None.

    Returns:
        (pd.DataFrame): The loaded data.
    """
    # Distinction du chemin selon l'année
    # Les données postérieures à 2021 n'étant pas disponibles, ce millésime est retenu en dernier ressort
    if year < 2022:
        # Chemin d'accès aux données
        table_path = f"\\\casd.fr\\casdfs\\Projets\\{project}\\Data\\Statistique annuelle d'entreprise_FARE_{year}"
        # Nom du jeu de données
        table_name = f"FARE{year}METH{year}.sas7bdat"
    else:
        # Chemin d'accès aux données
        table_path = f"\\\casd.fr\\casdfs\\Projets\\{project}\\Data\\Statistique annuelle d'entreprise_FARE_2021"
        # Nom du jeu de données
        table_name = f"FARE2021METH2021.sas7bdat"
    # Initialisation du loader
    loader = Loader()
    # Chargement des données
    data_fare = loader.load(
        path=os.path.join(table_path, table_name), columns=columns, filters=filters
    )

    return data_fare