def cap_feature_values(df, feature, cap_n=10):
    """Cap the values of a given feature, in order to reduce the
    effect of outliers.
    For example, set NUMBER_OF_HABITABLE_ROOMS values that are
    greater/equal to 10 to "10+".

    Paramters
    ----------
    df : pandas.DataFrame
        Given dataframe.

    feature : str
        Feature for which values are capped.

    cap_n : int, default=10
        At which value to cap.

    Return
    ---------
     df : pandas.DataFrame
        Dataframe with capped values."""

    # Cap at given limit (i.e. 10)
    df.loc[(df[feature] >= cap_n), feature] = cap_n  # str(cap_n) + "+"

    return df