def get_rdd_data(data, female=False):
    """Selects observations for RDD analysis (i.e close margin of victory in mixed gender race).

    :param (df)         data: df (originating from "main_dataset.dta")
    :param (bool)       female: if true restricts sample to female council candidates
    :return:            df
    """
    # creates sample for RDD

    if female:
        data1 = data.loc[(data["rdd_sample"] == 1) & (data["female"] == 1)].copy()

        return data1

    data1 = data.loc[(data["rdd_sample"] == 1)].copy()
    return data1