[Python] Creating dummy variables in pandas for python

Discussão em 'Python' iniciado por Stack, Abril 9, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to create a series of dummy variables from a categorical variable using pandas in python. I've come across the get_dummies function, but whenever I try to call it I receive an error that the name is not defined.

    Any thoughts or other ways to create the dummy variables would be appreciated.

    EDIT: Since others seem to be coming across this, the get_dummies function in pandas now works perfectly fine. This means the following should work:

    import pandas as pd

    dummies = pd.get_dummies(df['Category'])


    See http://blog.yhathq.com/posts/logistic-regression-and-python.html for further information.

    Continue reading...

Compartilhe esta Página