def filter_X_dilutions(df, concentration):
    """Select only one dilution ('high', 'low', or some number)."""
    assert concentration in ['high','low'] or type(concentration) is int
    df = df.sort_index(level=['CID','Dilution']) 
    df = df.fillna(999) # Pandas doesn't select correctly on NaNs
    if concentration == 'low':
        df = df.groupby(level=['CID']).first()
    elif concentration == 'high':
        df = df.groupby(level=['CID']).last()
    else:
        df = df.loc[[x for x in df.index if x[1]==concentration]]
        df = df.groupby(level=['CID']).last()
    df = df.replace(999,float('NaN')) # Undo the fillna line above. 
    return df