有一列数据,是公司名字
firm |
---|
The GM and Wuling Co. |
…… |
SGWM |
Gen M and Wuling |
同时,我还有一列用来识别的数据
id |
---|
GM Wuling |
SGWM |
GEN M WULING |
我希望,只要包含识别数据的字符串,都可以被判定出来。在例子中,所有的公司名,都应该被识别数据判定为对
【以下回答由 GPT 生成】
```python import pandas as pd
company_names = ["The GM and Wuling Co.", "SGWM", "Gen M and Wuling"] recognition_data = "GM Wuling, SGWM, GEN M WULING"
def check_company_names(company_names, recognition_data): result = [] for name in company_names: # 将公司名和识别数据都转为小写,方便比较 lowercase_name = name.lower() lowercase_recognition_data = recognition_data.lower()
# 判断公司名是否包含识别数据中的字符
if all(char in lowercase_name for char in lowercase_recognition_data):
result.append("对")
else:
result.append("错")
return result
result = check_company_names(company_names, recognition_data) result