Change set to list, error showed up

Hi all. I tried to change set(vocabulary) to list vocabulary), but errors showed. Can you help?

Screen Link:

My Code:

training_set['SMS'] = training_set['SMS'].str.split()

vocabulary = []
for sms in training_set['SMS']:
    for word in sms:

What I expected to happen:

vocabulary change to list type.

What actually happened:

AttributeError: Can only use .str accessor with string values, which use np.object_ dtype in pandas


training_set['SMS'] = training_set['SMS'].str.split()

is producing the error. Are you sure training_set['SMS'] data type is “object” (string) ?

A good way to debug it is to enter in a cell training_set['SMS'].str.split(), and look at the output.

I checked the training_set['SMS'] type. it is int64…but all is NAN

I guess it suppose to be string. You must have made mistake earlier so please share your notebook instead of code snippet so someone can review and suggest fixes if any.

You can look here to learn how to upload your notebook
(See 3rd and 4th steps)

Hi! Please see my nootbook. I think my dataset has a problem…

Problem One.ipynb (57.8 KB)

Click here to view the jupyter notebook file in a new tab

I tried it and it is working fine for me. Please try to re-run again with fresh kernel.