Spaces:
Sleeping
Sleeping
Update src/module/Validation_Contract.py
Browse files
src/module/Validation_Contract.py
CHANGED
|
@@ -117,6 +117,9 @@ class DataExplorer:
|
|
| 117 |
fig_mem.update_layout(title="Optimisation Mémoire (MB)", barmode='group')
|
| 118 |
st.plotly_chart(fig_mem, use_container_width=True)
|
| 119 |
|
|
|
|
|
|
|
|
|
|
| 120 |
with col2:
|
| 121 |
# Graphique 2 : Qualité Intrinsèque (Anomalies flagguées)
|
| 122 |
fig_qual = px.bar(
|
|
@@ -125,7 +128,8 @@ class DataExplorer:
|
|
| 125 |
labels={'x': 'Table', 'y': 'Nb Anomalies'},
|
| 126 |
color=anomalies, color_continuous_scale='Reds'
|
| 127 |
)
|
| 128 |
-
|
|
|
|
| 129 |
|
| 130 |
# Graphique 3 : Rétention des données
|
| 131 |
with st.expander("📊 Détails volumétrie et types"):
|
|
@@ -213,19 +217,20 @@ class ETL_Engine:
|
|
| 213 |
# 2. NUMÉRIQUES
|
| 214 |
for col in config.get('numeric', []):
|
| 215 |
if col in df.columns:
|
| 216 |
-
# On force d'abord en string pour nettoyer
|
| 217 |
if df[col].dtype == 'object':
|
| 218 |
-
#
|
| 219 |
-
#
|
| 220 |
-
|
|
|
|
|
|
|
|
|
|
| 221 |
|
| 222 |
-
# Nettoyage
|
|
|
|
| 223 |
df[col] = df[col].str.replace(r'\s+', '', regex=True)
|
| 224 |
-
|
| 225 |
-
# Gestion des valeurs vides ou erreurs textuelles
|
| 226 |
df[col] = df[col].replace(['Full', 'Erreur', 'full', 'erreur', '', 'nan', 'None'], np.nan)
|
| 227 |
|
| 228 |
-
# Conversion sécurisée
|
| 229 |
df[col] = pd.to_numeric(df[col], errors='coerce')
|
| 230 |
|
| 231 |
# 3. CATÉGORIELLES
|
|
@@ -286,9 +291,6 @@ class ETL_Engine:
|
|
| 286 |
summary = data_explorer.get_summary()
|
| 287 |
st.success(f"✅ ETL Terminé : {summary['total_rows']:,} lignes traitées.")
|
| 288 |
|
| 289 |
-
# APPEL DU DASHBOARD VISUEL
|
| 290 |
-
data_explorer.show_etl_report()
|
| 291 |
-
|
| 292 |
return True, data_explorer
|
| 293 |
|
| 294 |
except Exception as e:
|
|
|
|
| 117 |
fig_mem.update_layout(title="Optimisation Mémoire (MB)", barmode='group')
|
| 118 |
st.plotly_chart(fig_mem, use_container_width=True)
|
| 119 |
|
| 120 |
+
# AJOUT DU KEY UNIQUE ICI 👇
|
| 121 |
+
st.plotly_chart(fig_mem, use_container_width=True, key="chart_etl_memory")
|
| 122 |
+
|
| 123 |
with col2:
|
| 124 |
# Graphique 2 : Qualité Intrinsèque (Anomalies flagguées)
|
| 125 |
fig_qual = px.bar(
|
|
|
|
| 128 |
labels={'x': 'Table', 'y': 'Nb Anomalies'},
|
| 129 |
color=anomalies, color_continuous_scale='Reds'
|
| 130 |
)
|
| 131 |
+
# AJOUT DU KEY UNIQUE ICI 👇
|
| 132 |
+
st.plotly_chart(fig_qual, use_container_width=True, key="chart_etl_quality")
|
| 133 |
|
| 134 |
# Graphique 3 : Rétention des données
|
| 135 |
with st.expander("📊 Détails volumétrie et types"):
|
|
|
|
| 217 |
# 2. NUMÉRIQUES
|
| 218 |
for col in config.get('numeric', []):
|
| 219 |
if col in df.columns:
|
|
|
|
| 220 |
if df[col].dtype == 'object':
|
| 221 |
+
# --- FIX CRITIQUE "Int too large" ---
|
| 222 |
+
# On convertit d'abord en string pour mesurer la longueur
|
| 223 |
+
# Si une cellule a plus de 50 caractères, ce n'est pas un nombre valide pour l'analyse
|
| 224 |
+
# (Cela élimine le fameux nombre à 20 000 chiffres)
|
| 225 |
+
mask_too_long = df[col].astype(str).str.len() > 50
|
| 226 |
+
df.loc[mask_too_long, col] = np.nan
|
| 227 |
|
| 228 |
+
# Nettoyage standard pour les autres
|
| 229 |
+
df[col] = df[col].astype(str).str.replace(',', '.', regex=False)
|
| 230 |
df[col] = df[col].str.replace(r'\s+', '', regex=True)
|
|
|
|
|
|
|
| 231 |
df[col] = df[col].replace(['Full', 'Erreur', 'full', 'erreur', '', 'nan', 'None'], np.nan)
|
| 232 |
|
| 233 |
+
# Conversion sécurisée
|
| 234 |
df[col] = pd.to_numeric(df[col], errors='coerce')
|
| 235 |
|
| 236 |
# 3. CATÉGORIELLES
|
|
|
|
| 291 |
summary = data_explorer.get_summary()
|
| 292 |
st.success(f"✅ ETL Terminé : {summary['total_rows']:,} lignes traitées.")
|
| 293 |
|
|
|
|
|
|
|
|
|
|
| 294 |
return True, data_explorer
|
| 295 |
|
| 296 |
except Exception as e:
|