From 4b3c3c26e8c4d665fa4a9a6d8bce652372dc43bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20GUEZO?= Date: Fri, 6 Mar 2026 21:34:34 +0100 Subject: [PATCH] ajout: ajout prefixe get_dummies --- src/cleaning.py | 6 +++--- tests/test_cleaning.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cleaning.py b/src/cleaning.py index 4bf78bb..fed3b16 100755 --- a/src/cleaning.py +++ b/src/cleaning.py @@ -14,11 +14,11 @@ def path_filename(filename: str) -> str: class Cleaning: def __init__(self, filename) -> None: self._vins: DataFrame = read_csv(filename) - # + # créer la liste de tout les scores self.SCORE_COLS: list[str] = [ c for c in self._vins.columns if c not in ["Appellation", "Prix"] ] - # + # transforme tout les colonnes score en numérique for col in self.SCORE_COLS: self._vins[col] = to_numeric(self._vins[col], errors="coerce") @@ -87,7 +87,7 @@ class Cleaning: Remplace la colonne 'Appellation' par des colonnes indicatrices """ appellations = self._vins[column].astype(str).str.strip() - appellation_dummies = get_dummies(appellations) + appellation_dummies = get_dummies(appellations, prefix="App") self._vins = self._vins.drop(columns=[column]) self._vins = self._vins.join(appellation_dummies) return self diff --git a/tests/test_cleaning.py b/tests/test_cleaning.py index 28f42c6..00f8d0f 100755 --- a/tests/test_cleaning.py +++ b/tests/test_cleaning.py @@ -62,6 +62,6 @@ def test_encode_appellation(cleaning_raw: Cleaning): .encode_appellation() .getVins() ) - assert "Appellation" not in out.columns - assert "Pauillac" in out.columns - assert int(out.loc[0, "Pauillac"]) == 1 + assert "App_Appellation" not in out.columns + assert "App_Pauillac" in out.columns + assert int(out.loc[0, "App_Pauillac"]) == 1