0

I have column which contains 4000 unique values(rows). I want to delete values such as 'I__ND_LD(1),I__ND_LD(2),P__ND_LN(1),I__XF_XF(4)'.these values are unique in numbers in the brackets. for example. 'I__ND_LD(1) starts with 1 and end with 'I__ND_LD(70).

By this code,I can remove only one character using above function. I want to remove all the values as mentioned in the problem.

eda[~eda.Devices.str.Contains("^I__ND_LD(1)")]

Is there any other technique through which i can remove all these values, also we have different number of 'I__ND_LD' and 'P__ND_LN(1). I want to implement this in the function so that I can just pass the values and it delete all the values in the column.

anmol
  • 85
  • 1
  • 7

1 Answers1

1
to_remove = ['abc\(\d+\)', 'bca']
eda[~eda.devices.str.contains('|'.join(to_remove), regex=True)]
Vishnudev
  • 7,765
  • 1
  • 11
  • 43
  • I can remove single value using this. i have like abc(1),abc(2) tilll abc(70) and something like withe bca as well. – anmol Sep 05 '19 at 19:30
  • Use regex in the list, something like the updated answer @anmol – Vishnudev Sep 05 '19 at 19:32
  • It would be specific in your case and I can't tell you directly. If you need regex assistance the check this [link](https://stackoverflow.com/questions/22937618/reference-what-does-this-regex-mean). – Vishnudev Sep 05 '19 at 19:39