I have some code which plots variables with the same names in 2 different dataframes;
ax1.plot(df2[varname],'y-o',label='2')
ax1.plot(df1[varname],'g-o',label='1')
in some cases df2 may not have the variable, in which case I just want to chart the variable in df1, so just one line, and not 2.
This however, produces an error if the variable isn't in both dataframes. Is there an obvious solution I'm missing?