def filter_raw_data(df, min_entities=1, max_entities=10000000):
    """
    Removing sentences with 'min' and 'max' labels other than 'O'.

    Args:
        df: pd.DataFrame containing all sentences of the data.
        min_entities: int representing the min number of labels other than
        'O'.
        max_entities: int representing the max number of labels other than
        'O'.

    Returns:
        filtered_df: pd.DataFrame containing only
    """
    row_idxs_to_drop = []
    for row_idx, row in enumerate(df.iloc[:, 2]):
        labels = []  # appending all entity indices

        for e in row:
            if e != 'O':
                labels.append(e)

        if (len(labels) < min_entities) or (len(labels) >= max_entities):
            row_idxs_to_drop.append(row_idx)

    return df.drop(row_idxs_to_drop, axis=0)