Hi I have a list of dictionaries, each dictionary has a list of values. In that list there are nan
values which I wish to remove. Here is an example dictionary;
temp = {'A': ['field1', 'field2', 'field3', np.nan, np.nan], 'B': ['field1', 'field2', 'field3', 'field4', np.nan]}
which looks like;
{'A': ['field1', 'field2', 'field3', nan, nan], 'B': ['field1', 'field2', 'field3', 'field4', nan]}
I desired output is :
{'A': ['field1', 'field2', 'field3'], 'B': ['field1', 'field2', 'field3', 'field4']}
I've tired the following with no success;
res = {k:v for k,v in temp2.items() if v is not np.nan}
Any help is appreciated