一个Python初学者。你知道吗
我有一份20000种产品的清单及其描述。我的任务是找到所有包含类似“00320047S01”或“02201179S02”的项目的产品。你知道吗
The list of products with highlighted products numbers
我试过了
df1 = pd.read_excel(r'C:..\Desktop\Book1.xlsx') # Read the excel file
df1['A'] = df1['A'].astype(str).str.lower() # To lower case the data
new = df1['A'][df1['A'].str.contains(r'00[0-9]{6}S0[0-9]{2}',regex=True)].tolist() # trying out regex
[] #output
我哪里出错了?你知道吗
注:所有商品都没有随附图片所示的产品编号。你知道吗
尝试模式
r'00\d+S0\d+
或r'00\d{6}S\d{2}'
例如:
输出:
相关问题 更多 >
编程相关推荐