def payment_series(df, thresh=5):
    """Return true if user has series of payments of same amount.

    Default threshold series length is set to 5 based on
    data inspection: there is a substantial number of users
    who celarly seem to pay monthly but for whom the precise
    amount changes slightly after about 5 or 6 identical payments.

    Relies on equal rather than subsequent payments because
    subsequent payments are sensible to payments for mutliple
    cars (two parallel payment streaks on alternating dates),
    as well as to random/misclassified payments.
    """
    def helper(g):
        diff = g.amount.diff()
        longest = diff.cumsum().value_counts().max()
        g['series'] = longest >= thresh
        return g

    if df.empty:
        df['series'] = None
        return df
    df = df.sort_values(['user_id', 'amount'])
    return df.groupby('user_id').apply(helper)