python - "list indices must be integers, not list" with enumerate -


i have code

cnames = data["channelnames"] goodchannels = [i i,x in enumerate(cnames) if x!='skipped'] data["channelnames"]=cnames[goodchannels] 

i need channel numbers later, cnames[goodchannels] throws error "list indices must integers, not list"

the list made of integers. there way make work correctly?

cnames[np.array(goodchannels)] not work same error, assuming there else going on here.

you need list comprehension:

data["channelnames"] = [cnames[i] in goodchannels] 

Comments

Popular posts from this blog

Listboxes in c# -

Excel Duty List -

Multilayer CSV to filtered excel -