def filter_5v5_for_toi(df, **kwargs):
    """
    This method filters the given dataframe for minimum or max TOI or TOI60.

    This method groups at the player level. So if a player hits the minimum total but not for one or more teams
    they played for over the the relevant time period, they will be included.

    :param df: dataframe

    :param kwargs: relevant ones are min_toi, max_toi, min_toi60, and max_toi60

    :return: dataframe, filtered for specified players
    """
    toitotals = df[['PlayerID', 'TOION', 'TOIOFF']].groupby('PlayerID', as_index=False).sum()
    toitotals.loc[:, 'TOI60'] = toitotals.TOION / (toitotals.TOION + toitotals.TOIOFF)

    if 'min_toi' in kwargs:
        toitotals = toitotals.query('TOION >= {0:f}'.format(kwargs['min_toi'] / 60))  # TOION is in hrs; min_toi in mins
    if 'max_toi' in kwargs:
        toitotals = toitotals.query('TOION <= {0:f}'.format(kwargs['max_toi'] / 60))
    if 'min_toi60' in kwargs:
        toitotals = toitotals.query('TOI60 >= {0:f}'.format(kwargs['min_toi60']))
    if 'max_toi60' in kwargs:
        toitotals = toitotals.query('TOI60 <= {0:f}'.format(kwargs['max_toi60']))

    df2 = df.merge(toitotals[['PlayerID']], how='inner', on='PlayerID')
    return df2