# Why is patsy used to prepare data for logistic regression?

I'm pretty new to both ML & scikit-learn. I've noticed that some example tutorials & codes online use patsy's dmatrices to prepare data for logistic regression. I don't understand why this is done. Example

In the case above for instance, isn't it sufficient to use the data in the dataset directly to train the logistic regression model? What exactly is the point of using patsy?

Thanks!

## 1 Answer

Mostly convenience. In this particular case, it takes care of one-hot encoding categorical variables e.g. C(occupation).

patsy takes care of other things under the hood as well, like dropping rows with missing values and adding a constant intercept variable.