Defaultdict, set the default value to N/A. Alternatively if it’s only the final keys that are optional, you could do a bunch of .get()s but a Defaultdict is cleaner.
If you don’t care about huge dependencies, load into a pandas dataframe and use .fillna() but that’s usually overkill.
View all comments
Show parent comment
2
u/AchillesDev Jul 14 '21
Defaultdict, set the default value to N/A. Alternatively if it’s only the final keys that are optional, you could do a bunch of .get()s but a Defaultdict is cleaner.
If you don’t care about huge dependencies, load into a pandas dataframe and use .fillna() but that’s usually overkill.