Question: 3f) Masking the Zip Codes In this part, create a for loop, updating thedf_usersdataframe. Go through each user, and update their zip code, to Safe
3f) Masking the Zip Codes
In this part, create a for loop, updating thedf_usersdataframe.
Go through each user, and update their zip code, to Safe Harbor specifications:
- If the user is from a zip code for the which the "Geographic Subdivision" is less than equal to 20,000, change the zip code in df_users to '0' (as a string)
- Otherwise, zip should be only the first 3 numbers of the full zip code
- Do all this by directly updating thezipcolumn of thedf_usersDataFrame
Hints:
- This will be several lines of code, looping through the DataFrame, getting each zip code, checking the geographic subdivision with the population inzip_dict, and setting thezip_codeaccordingly.
- Be very aware of your variable types when working with zip codes here.
in python
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
