def clean_data(df, n_std=20):
    """Removes any outliers that are further than a chosen
    number of standard deviations from the mean.

    These values are most likely wrongly inputted data,
    and so are forward filled.

    :param df:          A time series
    :type  df:          pd.DataFrame

    :param n_std:       The number of standard deviations from the mean
    :type  n_std:       int

    :return:            The cleaned time series
    :rtype:             pd.DataFrame
    """
    upper = df.price.mean() + n_std * df.price.std()
    lower = df.price.mean() - n_std * df.price.std()
    df.loc[(df.price > upper) | (df.price < lower), 'price'] = None
    if df.price.isnull().sum() > 0:
        print('Rows removed:', df.price.isnull().sum())
    df.ffill(inplace=True)
    df = df[df.index.weekday_name != 'Saturday']
    df = df[df.index.weekday_name != 'Sunday']
    return df
