Replacing value not in list in Pandas
I don't know if it's the best way, but I'd write a function and apply it to the df['size']:
def rename_size(size):
    if size not in ['M','S','L']:
        return np.nan
    else:
        return size
df['size']= df['size'].apply(rename_size)