remove all nan in matrix code example
Example 1: python remove nan rows
df = df[df['my_var'].notna()]
Example 2: remove nans and infs python
x = x[numpy.logical_not(numpy.isnan(x))]
df = df[df['my_var'].notna()]
x = x[numpy.logical_not(numpy.isnan(x))]