import numpy as np temperatures = np.array([18.5, 21.0, 26.5, 31.0, 24.0]) hot_day_mask = temperatures >= 24 hot_days = temperatures[hot_day_mask] samples = np.array( [ [18.5, 0.91], [26.5, 0.98], [31.0, 0.99], [21.0, 0.87], ] ) valid_hot_rows = (samples[:, 0] >= 24) & (samples[:, 1] >= 0.95) selected_rows = samples[valid_hot_rows] assert hot_day_mask.shape == temperatures.shape assert valid_hot_rows.shape == (samples.shape[0],) assert hot_days.tolist() == [26.5, 31.0, 24.0] assert selected_rows.shape == (2, 2) print("temperatures:", temperatures) print("hot day mask:", hot_day_mask) print("hot days:", hot_days) print("hot day count:", hot_day_mask.sum()) print("row mask shape:", valid_hot_rows.shape) print("selected rows:") for row in selected_rows: print(" ", row.tolist()) try: temperatures[np.array([True, False])] except IndexError as error: print("shape error:", error)