Remove unwanted parts from strings in a column

前端 未结 9 1001
鱼传尺愫
鱼传尺愫 2020-11-22 15:48

I am looking for an efficient way to remove unwanted parts from strings in a DataFrame column.

Data looks like:

    time    result
1    09:00   +52A
         


        
9条回答
  •  青春惊慌失措
    2020-11-22 16:21

    i'd use the pandas replace function, very simple and powerful as you can use regex. Below i'm using the regex \D to remove any non-digit characters but obviously you could get quite creative with regex.

    data['result'].replace(regex=True,inplace=True,to_replace=r'\D',value=r'')
    

提交回复
热议问题