You can use np.isnan()
combined withany()
to index only the rows you want:
l = np.array([
[1, 2, 3],
[1, np.nan, 4],
[5, 6, 7],
[np.nan, np.nan, 7]
])
l[~(np.isnan(l).any(axis=1))]
#array([[1., 2., 3.],
# [5., 6., 7.]])
This uses ~
to invert the boolean values from isnan()
so you get the rows where it is false.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.