ajout : remplacer appellation par les colonnes indicatrices

This commit is contained in:
Chahrazad650
2026-03-03 03:26:58 +01:00
parent b0eb5df07e
commit 06097c257e
2 changed files with 22 additions and 1 deletions

View File

@@ -74,3 +74,18 @@ def fill_missing_scores(df: DataFrame) -> DataFrame:
df_copy = df_copy.drop(columns=temp_cols)
return df_copy
def encode_appellation(df: DataFrame, column: str = "Appellation") -> DataFrame:
"""
Remplace la colonne 'Appellation' par des colonnes indicatrices
"""
df_copy = df.copy()
appellations = df_copy[column].astype(str).str.strip()
appellation_dummies = pd.get_dummies(appellations)
df_copy = df_copy.drop(columns=[column])
return df_copy.join(appellation_dummies)