I’d like to replace the masked result with nan. Is there a way to do that directly with numpy’s masked_array? Answer filled method replaces the masked values with the fill value: Or as you do, specify the fill value when defining the array: The masked mean method skips over the filled values: