Vectorizing / Contrasting a Dataframe with Categorical Variables,df.apply(lambda x: pd.factorize(x)[0])