Error Converting

Hello, please I kept getting this error of ‘DataFrame’ object has no attribute ‘cat’ while converting the dataframe to an array. please help out

@steezyaremu Adding the link to your notebook would be helpful in determining the error. As the community can look into your code to find out the mistake.

Similar question here.

But in addition to that your output_cols variable needs to be a string or a list, but yours is a dataframe. So the dataframe_to_arrays() function cannot work on it.

Following changes are required in your notebook:
output_cols = dataframe.iloc[:,-1:]
output_cols = dataframe.columns[-1]

from: (do this for categorical_cols variable too)
input_cols = dataframe.drop(['charges'], axis=1).columns
input_cols = list(dataframe.drop(['charges'], axis=1).columns)

To be honest, this data is fairly small in dimensions. So maybe just entering the names of categorical columns and output columns names as lists is easier in this case. Yes df.columns filtering is cool but not necessary in this case.

1 Like