reflexion
reflexion

Reputation: 21

Converting Boolean array (i.e True False) into actual values?

I am trying to convert all true values in array 'v' to their actual numbers. Any suggestions would be highly appreciated.

import numpy as np
from numpy import load

dict_data = load('E_starData.npz')
EStar = dict_data['arr_0']
v = np.greater(EStar, 0.1)
print(v) #prints an array of true and false values, would like to display true values as the actual number

The code is pulling a saved zip file with all the data.

Upvotes: 0

Views: 91

Answers (2)

Ehsan
Ehsan

Reputation: 12407

You can use:

v = EStar * (EStar>0.1)

Upvotes: 1

Anson Biggs
Anson Biggs

Reputation: 342

There are probably better ways to approach the problem from the start, but building off of your code:

print([val for bool, val in zip(v, Estar) if bool])

Upvotes: 0

Related Questions