Created
July 23, 2020 14:08
-
-
Save bhuiyanmobasshir94/055de0c9953c282ebeb21d3bcf6c5aa5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def check_na(prev_dict): | |
new_dict = {key:val for key, val in prev_dict.items() if val != 'NA'} | |
return new_dict | |
def parse_na(payload): | |
fake_payload = {} | |
for k, v in payload.items(): | |
if isinstance(v,dict): | |
fake_payload[k] = check_na(v) | |
else: | |
if isinstance(v,list): | |
list_instance = [] | |
for val in v: | |
if isinstance(val,dict): | |
list_instance.append(check_na(val)) | |
else: | |
pass | |
fake_payload[k] = list_instance | |
else: | |
if v == 'NA': | |
fake_payload[k] = v | |
print(k) | |
return fake_payload |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment