Skip to content Skip to sidebar Skip to footer

Numpy: Stacking Masked Arrays And Calculating Min/max

I'm working with masked arrays and I want to calculate the max of different arrays/columns. I have problems, if the whole array is masked. Example: import numpy as np x = np.ma.ar

Solution 1:

With masked arrays, you need to use masked routines, that is numpy.ma. should precede method name:

>>> np.ma.hstack((x, y))
masked_array(data = [-- -- -- -- -- 5],
             mask = [ True  True  True  True  True False],
       fill_value = 999999)

>>> np.ma.max(np.ma.hstack((x, y)))
5

Post a Comment for "Numpy: Stacking Masked Arrays And Calculating Min/max"