mirror of
https://github.com/guezoloic/millesima_projetS6.git
synced 2026-03-28 11:03:41 +00:00
Merge branch 'jalon2-loic' of https://github.com/guezoloic/millesima_projetS6
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user