Factorizing strings with repeated values, pandas reference