Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Count Nan-Values per Column in an ndarray

Problem:
I have a ndarray (2000,7) and I want to count the numbers of Nan’s per column and save it in an ndarray

Tried:

number_nan_in_arr = np.count_nonzero(np.isnan(arr))

But this count the total number of nan’s over all columns

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Solution: ?

>Solution :

Simply sum the True values:

number_nan_in_arr = np.isnan(arr).sum(0)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading