def remove_duplicate(df_grouped, uid):
    """For each user, only take the first record for each question"""
    group = df_grouped.get_group(uid)
    user_questions = set()
    index = group.date.sort_values()
    rows = []
    for _, row in group.loc[index.index].iterrows():
        if row.qid in user_questions:
            continue
        user_questions.add(row.qid)
        rows.append(row)
    for j, row in enumerate(rows):
        rows[j].user_n_records = len(rows)
    return rows