remove nan values from numpy array code example
Example 1: remove nan from list python
cleanedList = [x for x in countries if str(x) != 'nan']
Example 2: python remove nan rows
df = df[df['my_var'].notna()]
Example 3: remove nans and infs python
x = x[numpy.logical_not(numpy.isnan(x))]
Example 4: remove nans and infs python
df.replace([np.inf, -np.inf], np.nan).dropna(axis=1)