Skip to content

Instantly share code, notes, and snippets.

@GermanCM
Last active June 16, 2020 07:47
Show Gist options
  • Save GermanCM/285b7831a324c993732f408013a9ab8e to your computer and use it in GitHub Desktop.
Save GermanCM/285b7831a324c993732f408013a9ab8e to your computer and use it in GitHub Desktop.
Example for filling nan values for an attribute
import numpy as np
not_nan_mask = np.isnan(np.array(bank_product_rec_santander_data.renta.values))==False
renta_values_not_nan=bank_product_rec_santander_data.renta.values[not_nan_mask]
sub_renta_mean = np.mean(renta_values_not_nan).round(2)
bank_product_rec_santander_sub_df['renta'] = bank_product_rec_santander_sub_df['renta'].fillna(value=sub_renta_mean)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment