Thank you @Matt Pitkin, your comment gave me the idea to solve my problem by doing away with the function and, instead using
if (df['a'] == 0).any().any(): # Check if any zero exists in the entire DataFrame
print("DataFrame contains zero values. Plotting aborted.")
else:
plt.plot(dfd[1], df['a'], color='g', label='a')
This works fine for me, except for 'b' which has all zeros it plots a straight line at 0. What I want is to avoid printing loads of error line when the column has no data.