0

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.

3
  • Can add a sample of your input ? Commented Apr 21, 2020 at 22:45
  • @MarkMeyer This will only include the non-zero values in a flat array and not EStar's shape. Commented Apr 22, 2020 at 0:15
  • 1
    Your right @Ehsan — it's not clear to me what the other values should be. Commented Apr 22, 2020 at 0:24

2 Answers 2

1

You can use:

v = EStar * (EStar>0.1) 
Sign up to request clarification or add additional context in comments.

Comments

0

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]) 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.