Skip to content
Advertisement

replace masked with nan in numpy masked_array

JavaScript

I’d like to replace the masked result with nan. Is there a way to do that directly with numpy’s masked_array?

Advertisement

Answer

JavaScript

filled method replaces the masked values with the fill value:

JavaScript

Or as you do, specify the fill value when defining the array:

JavaScript

The masked mean method skips over the filled values:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement