Search code examples
pythonpandasone-hot-encoding

TypeError: get_dummies() got an unexpected keyword argument 'drop_first'


Here's something I dont understand. When I run this:

dataframe['col_name'].str.get_dummies(sep='|', drop_first=True)

I get: TypeError: get_dummies() got an unexpected keyword argument 'drop_first' which makes no sense to me when I read this...

I must be missing something. Can anyone help?


Solution

  • There are 2 get_dummies:

    1. pandas.get_dummies
    2. pandas.Series.str.get_dummies

    The one you are using is the second one which does not have drop_first