I have a DataFrame object with 10 columns. 9 of those columns are of type object, 6 of which I'm trying to convert into type "category", since all of these columns contain a lot of duplicate values. Here's the piece of code for that:
for col in ['Col1', 'Col2', 'Col3', 'Col4', 'Col5', 'Col6']:
df[col] = df[col].astype('category')
But this code raises the following exception:
File "C:\Python27\lib\site-packages\pandas\core\arrays\categorical.py", line 378, in __init__
raise NotImplementedError("> 1 ndim Categorical are not "
NotImplementedError: > 1 ndim Categorical are not supported at this time
What might be the reason for this error message? I know, there are several questions similar to this one here, but those did not solve my problem. Any help would be much appreciated.