<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def std_filter(array, n_std=2.0, return_index=False):
 """Standard deviation outlier detector. :param array: array of data. :param n_std: default 2.0, exclude data out of ``n_std`` standard deviation. :param return_index: boolean, default False, if True, only returns index. """

    if not isinstance(array, np.ndarray):
        array = np.array(array)
    mean, std = array.mean(), array.std()

    good_index = np.where(abs(array - mean) <= n_std * std)
    bad_index = np.where(abs(array - mean) > n_std * std)

    if return_index:
        return good_index[0], bad_index[0]
    else:
        return array[good_index], array[bad_index]