我有两个excel文件。我必须根据特定列匹配它们并填充另一列。我在例子中向你解释。
示例: 2个excel文件:
monitered call.xlsx
在这个 excel 中有 2 张表,1. 打印添加 2. 数字
digital C2D.xlsx
单张是否有 Sheet1
监控呼叫.xlsx:
数字 C2D.xlsx
我必须将 Caller Number
与 CONTACT
匹配,如果两者都匹配,则从第二个 excel 中取出 REMARK
并粘贴到第一个 excel 中。
最后将更新后的数据保存到同一个sheet中的monitered call.xlsx中。
df = pd.read_excel(r'D:\Users\SPate233\Downloads\Alka\monitored calls.xlsx', sheet_name='digital')
df1 = pd.read_excel(r'D:\Users\SPate233\Downloads\Alka\digital C2D.xlsx', sheet_name='Sheet1')
答案 0 :(得分:0)
在 Pandas 数据帧中读取和存储两个工作表,并使用合并来获得您正在寻找的结果。 pandas 文档中有一些非常好的示例:https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.merge.html。如果您不熟悉连接,请查看:https://www.w3schools.com/sql/sql_join.asp。