goddol
goddol

Reputation: 1

get_dummies does not have columns attribute

This line of code:

for j in range(0,len(names)):
  #fullSet = pandas.get_dummies(fullSet,columns=[names[j]])
  fullSet = pandas.get_dummies(fullSet,columns=[categoricalNames.columns[j]])

Is generating this error:

Traceback (most recent call last):
  File "noPrintsMachineLearnOptions.py", line 109, in <module>
    fullSet = pandas.get_dummies(fullSet,columns=[categoricalNames.columns[j]])
TypeError: get_dummies() got an unexpected keyword argument 'columns'

This code runs on my machine with Python 2.7.12 without issue, but on my work's server with Python 2.7.13 I get the above error. There are countless examples on the web where columns is used with get_dummies so I do not understand what the problem is.

Upvotes: 0

Views: 328

Answers (1)

DavidG
DavidG

Reputation: 25370

It looks like the columns argument for get_dummies was introduced in pandas version 0.15. Therefore, if you are using a version < 0.15 (e.g. version 0.14), using columns will produce the error.

The solution would be to install the latest version of pandas

Upvotes: 1

Related Questions