import re
import pandas as pd
df=pd.DataFrame({'Description':['This is my mobile number 213 321 32111',
'another number 123 321 321',
'Hi, Shared accommodation is available in Lombard-IL. Single bed room and I preferred Veggie only. Please reach 630 828 3324 if any one interested. Thanks, Mohan']})
for i in range (len(df['Description'])):
print(re.sub(" \d+", " ",df.loc[i,"Description"]))
import openpyxl
import re
wb = openpyxl.load_workbook(r'pathtoexcel')
ph_no=r"\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}"
for sheet_name in wb.sheetnames:
ws = wb[sheet_name]
max_col_val = ws.max_column
max_row_val = ws.max_row
for cols in range(1,max_col_val + 1):
for rows in range(1,max_col_val):
if (ws.cell(rows, cols).value)!=None:
cl=ws.cell(rows, cols).value
if re.findall(ph_no, cl):
cl=re.sub(ph_no,"",cl)
此代码将忽略您描述中的所有数字
试试这个:
相关问题 更多 >
编程相关推荐