Python using numpy ~isnan()
Question: I'm new to Python. I'm trying to reduce the following peace of code.

    
    
    import numpy as np
    data = np.loadtxt('logfilename.txt')
    x = data[:,0]
    x = x[~np.isnan(x)]
    

to something like that:

    
    
    import numpy as np
    data = np.loadtxt('logfilename.txt')
    x = data[~np.isnan(data[:,0])]
    

But that doesn't work. Can anyone help me?

Very best


Answer: Following your code, you need to replace `x` with `data[:,0]` so it should be:

    
    
    x = data[:,0][~np.isnan(data[:,0])]
    

That's repetitive, why would you want that? Stay with the first one!

