edb-noumea 0.2.10__py3-none-any.whl → 0.2.12__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
edb_noumea/details.py CHANGED
@@ -96,8 +96,19 @@ def get_detailed_results():
96
96
  print("\nColonnes:", list(df.columns))
97
97
  print("Shape:", df.shape)
98
98
 
99
- # Sélectionne les colonnes par position et applique le mapping fixe
100
- expected_columns = [
99
+ # Sélection dynamique des colonnes bactéries par nom
100
+ # Recherche des colonnes contenant les mots-clés
101
+ e_coli_col = next((col for col in df.columns if "Escherichia" in str(col) or "coli" in str(col)), None)
102
+ entero_col = next((col for col in df.columns if "Entérocoques" in str(col)), None)
103
+
104
+ if e_coli_col is None or entero_col is None:
105
+ print(f"❌ Colonnes bactéries non trouvées dans le tableau extrait. Colonnes disponibles : {list(df.columns)}")
106
+ return None
107
+
108
+ # Sélectionne les 4 premières colonnes + colonnes bactéries trouvées
109
+ selected_cols = [df.columns[0], df.columns[1], df.columns[2], df.columns[4], e_coli_col, entero_col]
110
+ cleaned_df = df.loc[:, selected_cols].copy()
111
+ cleaned_df.columns = [
101
112
  "site",
102
113
  "point_de_prelevement",
103
114
  "date",
@@ -105,8 +116,6 @@ def get_detailed_results():
105
116
  "e_coli_npp_100ml",
106
117
  "enterocoques_npp_100ml"
107
118
  ]
108
- cleaned_df = df.iloc[:, :6].copy()
109
- cleaned_df.columns = expected_columns
110
119
 
111
120
  # Ajoute deux colonnes issues du split de 'point_de_prelevement'
112
121
  split_points = cleaned_df["point_de_prelevement"].str.split(",", n=1, expand=True)
@@ -118,10 +127,15 @@ def get_detailed_results():
118
127
  cleaned_df["heure"] = cleaned_df["heure"].astype(str)
119
128
 
120
129
  # Nettoyer et convertir les colonnes e_coli_npp_100ml et enterocoques_npp_100ml
121
- for col in ["e_coli_npp_100ml", "enterocoques_npp_100ml"]:
122
- if col in cleaned_df.columns:
123
- cleaned_df[col] = cleaned_df[col].replace(r"<\s*10", "10", regex=True)
124
- cleaned_df[col] = pd.to_numeric(cleaned_df[col], errors="coerce").astype('Int64')
130
+ # Appliquer la même technique à l'avant-dernière colonne (e_coli_npp_100ml)
131
+ if "e_coli_npp_100ml" in cleaned_df.columns:
132
+ cleaned_df["e_coli_npp_100ml"] = cleaned_df["e_coli_npp_100ml"].astype(str).str.replace(r"<\s*10", "10", regex=True)
133
+ cleaned_df["e_coli_npp_100ml"] = pd.to_numeric(cleaned_df["e_coli_npp_100ml"], errors="coerce").astype('Int64')
134
+
135
+ # Appliquer la même technique à la dernière colonne (enterocoques_npp_100ml)
136
+ if "enterocoques_npp_100ml" in cleaned_df.columns:
137
+ cleaned_df["enterocoques_npp_100ml"] = cleaned_df["enterocoques_npp_100ml"].astype(str).str.replace(r"<\s*10", "10", regex=True)
138
+ cleaned_df["enterocoques_npp_100ml"] = pd.to_numeric(cleaned_df["enterocoques_npp_100ml"], errors="coerce").astype('Int64')
125
139
 
126
140
  return cleaned_df
127
141
 
@@ -129,9 +143,12 @@ if __name__ == "__main__":
129
143
  # Obtenir le DataFrame des résultats détaillés
130
144
  detailed_df = get_detailed_results()
131
145
 
132
- # Afficher le DataFrame s'il a été créé avec succès
146
+ # Afficher seulement les colonnes demandées
133
147
  if detailed_df is not None:
134
- print("\n📋 Voici les détails des derniers relevés (toutes colonnes) :")
135
- print(detailed_df)
136
- print("\nColonnes du DataFrame :")
137
- print(list(detailed_df.columns))
148
+ print("\n📋 Détails synthétiques :")
149
+ print(detailed_df[[
150
+ "point_de_prelevement",
151
+ "date",
152
+ "e_coli_npp_100ml",
153
+ "enterocoques_npp_100ml"
154
+ ]])
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: edb-noumea
3
- Version: 0.2.10
3
+ Version: 0.2.12
4
4
  Summary: Un scraper pour la qualité des eaux de baignade à Nouméa.
5
5
  Project-URL: Homepage, https://github.com/adriens/edb-noumea
6
6
  Project-URL: Repository, https://github.com/adriens/edb-noumea
@@ -0,0 +1,7 @@
1
+ edb_noumea/__init__.py,sha256=G7WKTGLsr2wtW1E2jYpqq4miZLoSGhTifSE36CGNkLo,60
2
+ edb_noumea/details.py,sha256=xjjip8EQwhWe2i-wqJQ9ZDBQIvChSey_LZsOX1M9Fxw,6890
3
+ edb_noumea/main.py,sha256=KWT0ZGrHlbhEsQxi_Rw0Mm1syDIxoY-Px1yab94IbJc,2115
4
+ edb_noumea-0.2.12.dist-info/METADATA,sha256=DTbuQ4wh0FM6wSxR8hlnIdwydkgCs2oYe6wpo_PiKqQ,396
5
+ edb_noumea-0.2.12.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
6
+ edb_noumea-0.2.12.dist-info/top_level.txt,sha256=Dj3JusM0b5H9_f9yZeO-IwucCZzI1OHSjLMKtvRjq6k,11
7
+ edb_noumea-0.2.12.dist-info/RECORD,,
@@ -1,7 +0,0 @@
1
- edb_noumea/__init__.py,sha256=G7WKTGLsr2wtW1E2jYpqq4miZLoSGhTifSE36CGNkLo,60
2
- edb_noumea/details.py,sha256=6mIFqB1bpt7bl9D3qhHGXE7uBL_oePgPuJf9dqbiQlE,5794
3
- edb_noumea/main.py,sha256=KWT0ZGrHlbhEsQxi_Rw0Mm1syDIxoY-Px1yab94IbJc,2115
4
- edb_noumea-0.2.10.dist-info/METADATA,sha256=RHWREnR-vbrA-5XdlUxd6XxWV9spwiJXZxR1ECfaYBE,396
5
- edb_noumea-0.2.10.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
6
- edb_noumea-0.2.10.dist-info/top_level.txt,sha256=Dj3JusM0b5H9_f9yZeO-IwucCZzI1OHSjLMKtvRjq6k,11
7
- edb_noumea-0.2.10.dist-info/RECORD,,