How can I add up all the elements of each row of a multidimensional numpy array. I am trying to turn the '--' elements to 0 and then adding all the rows right after. How could I do such a thing? The -- elements of the result of the masked array.
Array = np.array([[--, --, --, --, --, --, --]
[3, 4, --, --, --, --, --]
[--, --, 5, 7, 8, 10, --]
[--, --, --, --, --, --, --]
[--, --, --, --, --, --, 20]])
np.where(Array != "--", result, 0)
Array.sum(axis=0)
Expected Output:
[0 7 30 0 20]
"--"Array.Array = np.array([[--, --, --, --, --, --, --] [3, 4, --, --, --, --, --] [--, --, 5, 7, 8, 10, --] [--, --, --, --, --, --, --] [--, --, --, --, --, --, 20]])should throw an error.