Created
March 12, 2022 01:35
-
-
Save terrah27/0eb7003345be2e0f9506723383c52e5e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# impute using fillna | |
# make a copy of dataframe for example purposes | |
imputed_df = df_threshold.copy() | |
# list of columns to impute | |
impute_cols = ['AMT_REQ_CREDIT_BUREAU_YEAR', | |
'AMT_REQ_CREDIT_BUREAU_HOUR', | |
'AMT_REQ_CREDIT_BUREAU_DAY', | |
'AMT_REQ_CREDIT_BUREAU_WEEK', | |
'AMT_REQ_CREDIT_BUREAU_MON', | |
'AMT_REQ_CREDIT_BUREAU_QRT'] | |
# fill missing values with mean | |
for col in impute_cols: | |
imputed_df[col] = imputed_df[col].fillna(imputed_df[col].mean()) | |
# get updated missing value info | |
get_missing_values_info(imputed_df).head(20) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment