读取A表中对应村的客户姓名,到B表中查询是否存在对应记录,如果存在对应记录则打印出当前客户姓名
import pandas as pd
def find_and_show_existing_records(ids_series, excel_file):
for sheet_name in pd.ExcelFile(excel_file).sheet_names:
df_sheet = pd.read_excel(excel_file, sheet_name=sheet_name)
existing_records = df_sheet[df_sheet['纳税人名称'].isin(ids_series)]
if not existing_records.empty:
print(f"在'{sheet_name}'工作表中找到以下记录:")
print(existing_records['纳税人名称'])
else:
print(f"在'{sheet_name}'工作表中没有找到匹配的身份证号。")
df = pd.read_excel('C:\\Users\\X\\Desktop\\2025年未领取待遇缴费情况表.xlsx')
df=df[df['村、分场']=='喜羊村']
df=df['姓名']
for name in df:
find_and_show_existing_records(df, 'C:\\Users\\X\\Desktop\\新建文件夹\\地税移交备份\\2022年临河区城乡居民基本养老保险费(2).xlsx')