Ignore le genre inconnu dans la répartition
This commit is contained in:
parent
d5ff3cd076
commit
cc613a88af
@ -274,7 +274,7 @@ Le script lit `data/intermediate/minifigs_by_set.csv` et `data/intermediate/sets
|
|||||||
1. `source .venv/bin/activate`
|
1. `source .venv/bin/activate`
|
||||||
2. `python -m scripts.plot_minifig_gender_share`
|
2. `python -m scripts.plot_minifig_gender_share`
|
||||||
|
|
||||||
Le script lit `data/intermediate/minifigs_by_set.csv`, agrège le nombre de minifigs distinctes par genre (basé sur `config/known_character_genders.csv`), écrit `data/intermediate/minifig_gender_counts.csv`, puis trace `figures/step25/minifig_gender_share.png` (donut indiquant la part des personnages féminins, masculins ou inconnus).
|
Le script lit `data/intermediate/minifigs_by_set.csv`, agrège le nombre de minifigs distinctes par genre (basé sur `config/known_character_genders.csv`), écrit `data/intermediate/minifig_gender_counts.csv`, puis trace `figures/step25/minifig_gender_share.png` (donut indiquant la part des personnages féminins et masculins, les genres inconnus étant ignorés pour ce graphique).
|
||||||
|
|
||||||
### Étape 26 : corrélation pièces / minifigs
|
### Étape 26 : corrélation pièces / minifigs
|
||||||
|
|
||||||
|
|||||||
@ -17,7 +17,9 @@ def load_gender_counts(path: Path) -> List[dict]:
|
|||||||
|
|
||||||
def plot_minifig_gender_share(counts_path: Path, destination_path: Path) -> None:
|
def plot_minifig_gender_share(counts_path: Path, destination_path: Path) -> None:
|
||||||
"""Trace un diagramme circulaire de la répartition des minifigs par genre."""
|
"""Trace un diagramme circulaire de la répartition des minifigs par genre."""
|
||||||
rows = load_gender_counts(counts_path)
|
rows = [
|
||||||
|
row for row in load_gender_counts(counts_path) if row["gender"].strip().lower() in ("male", "female")
|
||||||
|
]
|
||||||
if not rows:
|
if not rows:
|
||||||
return
|
return
|
||||||
genders = [row["gender"] for row in rows]
|
genders = [row["gender"] for row in rows]
|
||||||
|
|||||||
@ -17,7 +17,7 @@ def test_plot_minifig_gender_share(tmp_path: Path) -> None:
|
|||||||
"gender,minifig_count\n"
|
"gender,minifig_count\n"
|
||||||
"male,2\n"
|
"male,2\n"
|
||||||
"female,1\n"
|
"female,1\n"
|
||||||
"unknown,1\n"
|
"unknown,5\n"
|
||||||
)
|
)
|
||||||
|
|
||||||
plot_minifig_gender_share(counts_path, destination)
|
plot_minifig_gender_share(counts_path, destination)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user