Python for MATLAB Users
Justin Kiggins
Product Manager
data = np.array([0.967, 0.56, 0.171, 0.872]) threshold = 0.85
meets_criteria = data > threshold
print(meets_criteria)
[True, False, False, True]
data = np.array([-1, 0.56, -1, 0.872, 1.26])
is_valid = data >= 0
valid_data = data[is_valid]
print(valid_data)
[0.56, 0.872, 1.26]
monkeys = df['animal'] == 'monkey' bears = df['animal'] == 'bear'
monkey_weight = df[monkeys]['weight'].mean() bear_weight = df[bears]['weight'].mean()
print(monkey_weight)
35.0
print(bear_weight)
800.0
Python for MATLAB Users