Files
code-sandbox/np-demo.py
T
2019-06-22 22:37:24 +10:00

24 lines
501 B
Python

# Create 2 new lists height and weight
import numpy as np
height = [1.87, 1.87, 1.82, 1.91, 1.90, 1.85]
weight = [81.65, 97.52, 95.25, 92.98, 86.18, 88.45]
# Import the numpy package as np
# Create 2 numpy arrays from height and weight
np_height = np.array(height)
np_weight = np.array(weight)
print(type(np_height))
# Calculate bmi
bmi = np_weight / np_height ** 2
# Print the result
print(bmi)
# For a boolean response
# bmi > 23
# Print only those observations above 23
print(bmi[bmi > 25])