margret azuma
margret azuma

Reputation: 3

Numpy sum() function

I am correctly trying to figure out what a piece of code means and I came across this code which I do not understand. Could someone explain this to me?

if np.sum((arr_y != arr_y)) == 0:
    print(True)

Upvotes: 0

Views: 43

Answers (1)

Jérôme Richard
Jérôme Richard

Reputation: 50278

arr_y != arr_y is generally used to check NaN values as they are the only one to be different from themselves. Thus, this code just check the number of NaN values is 0 and print True if so.

Upvotes: 1

Related Questions