I have a script written where a list is created from the column of a file. Within this list there are many nan entries randomly placed. How can i remove these entries? Heres my code :
#import astropy.io.ascii as asciitable
import numpy as np
import pylab as plt
#x=asciitable.read('protected.txt', guess=False,delimiter='\t',fill_values=[('', '-999')])
#x=np.genfromtxt('protected.txt', comments='#', delimiter=' ', skiprows=0, skip_header=0, skip_footer=0, converters=None, missing='', missing_values='', filling_values=-999, usecols=None, names=None, excludelist=None, deletechars=None, replace_space='_', autostrip=False, case_sensitive=True, defaultfmt='f%i', unpack=None, usemask=False, loose=True, invalid_raise=True)
x=np.load('EC/EC_data')
# Convert columns to float values
BMI=map(float,x['bmiEC'])
print BMI
heres the traceback:
TypeError Traceback (most recent call last)
/example_bmiEC.py in <module>()
8 # Convert columns to float values
9 BMI=map(float,x['bmiEC'])
---> 10 BMI=BMI[~np.isnan(BMI)]
11 print BMI
TypeError: only integer arrays with one element can be converted to an index
WARNING: Failure executing file: <example_bmiECFSPR.py>
nan entry
is? / And why is half your code commented out? What exactly are you asking? What have you tried?