Home > Software engineering >  pandas string remove selective value combination
pandas string remove selective value combination

Time:10-31

Hi I have pandas df with string "1) some text WH-1162" some words: 1011,4; 2) some other text: 1 pc; 3) CBHU8512454, number:2; 8) Code:000;"

I wont to get rid of all combinations like "1)" from string but keep other numbers. How can I make it selective so that code recognizes combination to remove

I did not find any workable solution

CodePudding user response:

You can remove the numbers with round bracket such as 1), 2), ... from a string like this:

df['column'] = df['column'].str.replace(r'\d\)', '')
  • Related