def group_survival_table_from_events(groups, durations, event_observed, birth_times=None, limit=-1):

    n = np.max(groups.shape)
    assert n == np.max(durations.shape) == np.max(event_observed.shape), "inputs must be of the same length."

    if birth_times is None:
        # Create some birth times
        birth_times = np.zeros(np.max(durations.shape))
        birth_times[:] = np.min(durations)

    assert n == np.max(birth_times.shape), "inputs must be of the same length."

    groups, durations, event_observed, birth_times = [pd.Series(np.reshape(data, (n,))) for data in [groups, durations, event_observed, birth_times]]
    unique_groups = groups.unique()

    for i, group in enumerate(unique_groups):
        ix = groups == group
        T = durations[ix]
        C = event_observed[ix]
        B = birth_times[ix]
        group_name = str(group)
        columns = [event_name + ":" + group_name for event_name in ['removed', 'observed', 'censored', 'entrance', 'at_risk']]
        if i == 0:
            data = survival_table_from_events(T, C, B, columns=columns)
        else:
            data = data.join(survival_table_from_events(T, C, B, columns=columns), how='outer')

    data = data.fillna(0)
    # hmmm pandas its too bad I can't do data.ix[:limit] and leave out the if.
    if int(limit) != -1:
        data = data.ix[:limit]

    return unique_groups, data.filter(like='removed:'), data.filter(like='observed:'), data.filter(like='censored:')
A filter on a FK respects the FK's to_field attribute (#17972).
dataset/ETHPy150Open CamDavidsonPilon/lifelines/lifelines/utils/__init__.py/group_survival_table_from_events--crossover with--dataset/ETHPy150Open django/django/tests/admin_filters/tests.py/ListFiltersTests.test_fk_with_to_field