Created
April 3, 2021 15:25
-
-
Save HeenaR17/39ebc838195d453dd77ea4c49508ac19 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
# Replacing missing values in Glucose column with median of respective class. | |
def impute_Glucose(cols): | |
Glucose=cols[0] | |
Outcome=cols[1] | |
if pd.isnull(Glucose): | |
if Outcome == 0: | |
return 120 | |
else: | |
return 142 | |
else: | |
return Glucose | |
df_copy['Glucose']=df_copy[['Glucose','Outcome']].apply(impute_Glucose, axis=1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment