Delete whole 3d array if contains any nan
Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn
--
Music by Eric Matyas
https://www.soundimage.org
Track title: The World Wide Mind
--
Chapters
00:00 Question
00:58 Accepted answer (Score 1)
01:27 Thank you
--
Full question
https://stackoverflow.com/questions/7107...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #numpyndarray
#avk47
--
Music by Eric Matyas
https://www.soundimage.org
Track title: The World Wide Mind
--
Chapters
00:00 Question
00:58 Accepted answer (Score 1)
01:27 Thank you
--
Full question
https://stackoverflow.com/questions/7107...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #numpyndarray
#avk47
ACCEPTED ANSWER
Score 1
As already answered by Michael Szczesny, more Pythonic way would be:
filtered_images=a[~np.isnan(a).any(axis=(2,1))]
If that piece of code is hard to understand, then consider extracting each image with a for loop as follows:
filtered_images=list()
for value in a:
if(np.isnan(value).any()!=True):
filtered_images.append(value)
Both approaches should give you similar output!