python - Print array element with False value -


in python, how can print elements false value? here code:

import numpy np  height = [1.65, 1.75, 1.71, 1.72, 1.69, 1.68, 1.67, 1.70] weight = [60, 65, 88, 59, 78, 77, 79, 72]  # calculate , print bmis bmi = np.array(weight) / np.array(height) print("the values of bmis:", bmi)  # create array bmi status (true/false) less 40 true_false_bmi = np.array(bmi) < 40  # print out whole true_false_bmi array true/false print("status of bmis (criteria -> less 40):", true_false_bmi)  # print out bmis less 40 print("bmis less 40:", bmi[true_false_bmi]) 

upto working fine. want print bmis above 40. have tried following codes , not working:

# print out bmis of baseball players bmi above 40 i.e., false elements of true_false_bmi array. print("bmis above 40:", bmi[!true_false_bmi]) print("bmis above 40:", bmi[not true_false_bmi]) 

you can use ~ operator negation in numpy.

print("bmis above 40:", bmi[~true_false_bmi]) 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -