How can I remove all non-numeric characters from all the values in a particular column in pandas dataframe?

后端 未结 5 1861
清酒与你
清酒与你 2020-11-30 05:43

I have a dataframe which looks like this:

     A       B           C
1   red78   square    big235
2   green   circle    small123
3   blue45  triangle  big657         


        
5条回答
  •  粉色の甜心
    2020-11-30 06:39

    You can use .str.replace with a regex:

    dfObject['C'] = dfObject.C.str.replace(r"[a-zA-Z]",'')
    

    output:

            A         B    C
    1   red78    square  235
    2   green    circle  123
    3  blue45  triangle  657
    

提交回复
热议问题