Cap extreme values

Mediummeanstdclip· 20 XP

A couple of huge orders are throwing off an average. A common fix is to cap values: anything more than 2 standard deviations from the mean is pulled back to that limit. The numbers are illustrative.

Work out the mean and standard deviation of orders, then store the array with every value limited to the range mean - 2 × std to mean + 2 × std, rounded to 2 decimals.

Expected answer

Store it in result: a NumPy array of shape (12,).

import numpy as np

orders = np.array([42.0, 38.5, 51.0, 47.25, 40.0, 390.0, 44.5, 36.0, 49.0, 41.75, 2.0, 45.0])
result = ...