How to neglect Nan values

Hello,
I used the qa_flag>0.5 for SO2 values and I got some missing spots in the plot.
My question is: How can I neglect these Nan values so that the function gives me the mean value of a Box without counting the NAN values.
Thank you in advance,
Ismail

It looks like you already asked this question here. How is this question different?

Yes sorry. You answered that correctly in the last question. I just wanted to make the question detailed here.