Created
March 12, 2022 01:51
-
-
Save terrah27/d3e209aff0453db2447fea359caf1738 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
# check number of missing values | |
print(f"Missing Values Before Flagging: {df['OCCUPATION_TYPE'].isnull().sum()}") | |
# check values of OCCUPATION_TYPE feature | |
print(df['OCCUPATION_TYPE'].value_counts()) | |
# replace values with flag 1=data present 0=data missing | |
df['OCCUPATION_TYPE'] = np.where(df['OCCUPATION_TYPE'].isnull(), # condition | |
1, # value if true | |
0 # value if false | |
) | |
# check number of missing values | |
print(f"Missing Values After Flagging: {df['OCCUPATION_TYPE'].isnull().sum()}") | |
# check values of OCCUPATION_TYPE feature | |
df['OCCUPATION_TYPE'].value_counts() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment