ajout: restructuration du code

This commit is contained in:
2026-03-05 22:06:00 +01:00
parent 8047b06253
commit 69b8b4ce1f
5 changed files with 13 additions and 17 deletions

View File

@@ -1,7 +1,12 @@
[project]
name = "projet-millesima-s6"
version = "0.1.0"
dependencies = ["requests==2.32.5", "beautifulsoup4==4.14.3", "pandas==2.3.3", "tqdm==4.67.3"]
dependencies = [
"requests==2.32.5",
"beautifulsoup4==4.14.3",
"pandas==2.3.3",
"tqdm==4.67.3",
]
[project.optional-dependencies]
test = ["pytest==8.4.2", "requests-mock==1.12.1", "flake8==7.3.0"]

View File

@@ -1,6 +1,5 @@
#!/usr/bin/env python3
from pandas import DataFrame, to_numeric
import pandas as pd
from pandas import DataFrame, to_numeric, get_dummies
SCORE_COLS = ["Robert", "Robinson", "Suckling"]
@@ -51,8 +50,6 @@ def mean_score(df: DataFrame, col: str) -> DataFrame:
means = means.rename(columns={col: f"mean_{col}"})
return means
def mean_robert(df: DataFrame) -> DataFrame:
return mean_score(df, "Robert")
@@ -99,7 +96,7 @@ def encode_appellation(df: DataFrame, column: str = "Appellation") -> DataFrame:
appellations = df_copy[column].astype(str).str.strip()
appellation_dummies = pd.get_dummies(appellations)
appellation_dummies = get_dummies(appellations)
df_copy = df_copy.drop(columns=[column])

View File

@@ -5,13 +5,7 @@ from os.path import normpath, join
from sys import argv
from pandas import read_csv, DataFrame
from cleaning import (display_info,
drop_empty_appellation,
mean_robert,
mean_robinson,
mean_suckling,
fill_missing_scores,
encode_appellation)
from cleaning import *
def load_csv(filename: str) -> DataFrame:

0
tests/test_cleaning.py Normal file → Executable file
View File

0
tests/test_scraper.py Normal file → Executable file
View File