0

I have a data table which some text columns. I want to delete those rows which have MN followed by some number. For instance MN 894080/901060/905034,MN 90706 etc.

import pandas as pd
data= [
"MN 894080/901060/905034 - a file has some text.",
"L2 BLOCK AMER] [VVol MN 941737][DU MN 934010] a file has some text",
"MN 907068 || bdheks;",
"MN#287627/901060/905034 a file has some text ",
"MN# 944179 || a file has some text",
"(MN #927427)a file has some text",
"MN 933281 - a file has some text",
"a file has some text",
" a file has some text Mnuq"]
df<-pd.DataFrame(data)

Final output should look like below:

df
  data
a file has some text
a file has some text Mnuq
user15051990
  • 1,835
  • 2
  • 28
  • 42

1 Answers1

0
import pandas as pd
data= [
"MN 894080/901060/905034 - a file has some text.",
"L2 BLOCK AMER] [VVol MN 941737][DU MN 934010] a file has some text",
"MN 907068 || bdheks;",
"MN#287627/901060/905034 a file has some text ",
"MN# 944179 || a file has some text",
"(MN #927427)a file has some text",
"MN 933281 - a file has some text",
"a file has some text",
" a file has some text Mnuq"]

_re_remove = re.compile('MN.*\d+')
df = pd.DataFrame(row for row in data if not _re_remove.search(row))
nosklo
  • 217,122
  • 57
  • 293
  • 297