Skip to content Skip to sidebar Skip to footer

Series' Object Has No Attribute 'decode In Pandas

I am trying to decode utf-8 encoded text in python. The data is loaded to a pandas data frame and then I decode. This produces an error: AttributeError: 'Series' object has no attr

Solution 1:

I could be wrong but I would guess that what you have are byte strings rather than strings of bytes strings b"XXXXX" instead of "b'XXXXX'" as you've posted in your answer in which case you could do the following (you need to use the string accessor):

preparedData['text'] = preparedData['text'].str.decode('utf8')

Edit: Looks like my assumption was wrong, in which case you can do a pre-processing step:

import ast
preparedData['text'] = preparedData['text'].apply(ast.literal_eval).str.decode("utf-8")

Post a Comment for "Series' Object Has No Attribute 'decode In Pandas"