1

Say we are using pandas.get_dummies to dummy coding our categorial variable. My question is how to set the reference level for a categorical variable, so that I can specify which level to drop when I use drop_first argument in get_dummies? This can be easily done in R, since R has factor datatype. I'm not sure how to do it in pandas. Thanks.

dt = pd.Series(list('abcdab'))
pd.get_dummies(dt, drop_first=True)
zesla
  • 11,155
  • 16
  • 82
  • 147
  • Does this answer your question? [How to create dummy variables using pandas with reference to one value?](https://stackoverflow.com/questions/58868967/how-to-create-dummy-variables-using-pandas-with-reference-to-one-value) – C8H10N4O2 Aug 19 '21 at 15:32

0 Answers0