简体   繁体   中英

How can I remove u- unicode character from my data frame column which is string consisting of a dict?

I have a dataframe with columns as shown:

   CA   CB      CC
    0   1   2   {u'video3d': {u'data': {u'annotations':[u'....

I want to remove u from the column CC. I tried using apply(lambda x: ast.literal_eval(json.dumps(x))) , but it is not working. I read this data from a csv and the type for the column is string.

If you are reading this from a csv , just do :

df['CC'].replace('u','',regex=True)

Since the dtype is object , the general string replace method should work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM