I have two dataframes
DF1:
EmployeeID CollectiveBargainingUnit BusinessGroup ProfitCenter Eligible
1 12A A12 UGZ.
2 17A B12 MGZ.
3 18A C12 DGZ.
4 19A D12 XGZ.
DF2:
CollectiveBargainingUnit BusinessGroup ProfitCenter Eligible
12A A12 UGZ. True
17A B12 MGZ. False
18A C12 DGZ. False
19A D12 XGZ. True
12A A13 UGZ. False
27A C12 MKZ. True
32A C22 DGZ. True
19A D99 XGZ. False
What would I would like to accomplish is this
EmployeeID CollectiveBargainingUnit BusinessGroup ProfitCenter Eligible
1 12A A12 UGZ. True
2 17A B12 MGZ. False
3 18A C12 DGZ. False
4 19A D12 XGZ. True
Based off of multiple columns between the two Dataframes (CollectiveBargainingUnit BusinessGroup ProfitCenter) I'd like to access it's eligibility in DF2 and update it in DF1
Where I am left off is:
eligibility_map=df2.groupby(["BusinessGroup","ProfitCenter","CollectiveBargainingUnit"]).first()["Eligible"]
df1["Eligible"] = df1["BargainingUnit"].map(eligibility_map).fillna(df1["Eligible"])
I can't map it to only one column. I need to map to multiple columns at once.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…