Filter list of tuples. I tried a few things but the didn't work:
import numpy as np
import sys
import math
#Python Version: 3.8.1
ZL = [('2011',np.nan),('2012',np.nan),('2013','B'),('2014','C')]
#~ Desired output: [('2013',20),('2014',34)]
# I tried the following:
#~ cleanedZL = filter(lambda x:x[1] != np.nan,ZL) # Does not work
#~ cleanedZL = filter(lambda x:x[1] != 'nan',ZL) # Does not work
#~ cleanedZL = [i for i in ZL if not math.isnan(i[1])] # Does not work
#~ cleanedZL = [i for i in ZL if i[1] != np.nan] # Does not work
cleanedZL = [i for i in ZL if i[1] != 'nan'] # Does not work
for a in cleanedZL:
print (a)