import pickle


def get_earlier_cpds(month):
    """ Finds all compounds which were inputted into SureChemBL prior to or equal
    to a given month

    Args:
        month (string): Month, in the form YYYY-MM

    Returns:
        pandas dataframe: dataframe containing SureChemBL patent id, month of
        first entry, and igraph index
    """
    #Read in master compound-date-index dataframe
    agave_fp = "Data/Cpd_Data/master_cpd_date_index_df.p"
    #drive_fp = "G:/Shared drives/SureChemBL_Patents/Cpd_Data/master_cpd_date_index_df.p"
    df = pickle.load(file=open(agave_fp, "rb"))

    # #Small dataframe analysis
    # check_indicies(df)

    return df[df["Month"] <= month]