intial commit (forked from private repo)
This commit is contained in:
13
extracted_cells/cell8.py
Normal file
13
extracted_cells/cell8.py
Normal file
@ -0,0 +1,13 @@
|
||||
# Ersetzen von '?' durch NaN und dann durch den häufigsten Wert
|
||||
df_clean = df.copy()
|
||||
|
||||
for col in df_clean.columns:
|
||||
if df_clean[col].dtype == 'object':
|
||||
# Ersetze '?' durch NaN
|
||||
df_clean[col] = df_clean[col].replace('?', np.nan)
|
||||
|
||||
# Ersetze NaN durch den häufigsten Wert
|
||||
most_frequent = df_clean[col].mode()[0]
|
||||
df_clean[col] = df_clean[col].fillna(most_frequent)
|
||||
|
||||
df_clean.head(10)
|
||||
Reference in New Issue
Block a user