使用熊猫合并Excel工作表中的两列

时间:2020-02-15 13:57:12

标签: excel python-3.x pandas

我有两个Excel工作表,其中包含标签“列名”,“别名”,“表”。别名在这两个excel工作簿中都很常见。

File1.xlsx

TABLE   ALIAS
Employee    ON
Department  Dept
Customer    Cust 

File2.xlsx

ALIAS   COLUMN
Employee    EmpID
Dept    DeptName
Dept    DeptID
Employee    EmpName 

这里的逻辑应如下所示:

代码

dfFile1 = pd.read_excel("File1.xlsx")
dfFile2 =  pd.read_excel("File2.xlsx") 
if(dfFile1.Alias == "ON"):
    if(dfFile1.Table.value == dfFile2.ALias.value):
        # some code 
        to merge "TABLE" && "COLUMN"```
The output should like below
TABLE   COLUMN
Employee    EmpID
Employee    EmpName

0 个答案:

没有答案