如何組合三個數據幀,如下所示?根據條件合併3個不同的數據幀
前兩個的主要關係必須基於ID1,因爲它是兩個數據框之間的匹配關係。
第三個數據幀,地址2必須以哈希添加
DF1匹配:
Name1 Name2 Name3 Address ID1 ID2 Own
Matt John1 Jill 878 home 1 0 Deal
Matt John2 Jack 879 home 2 1 Dael
DF2:
Name1 ID1 Address Name4 Address2
Matt 1 878 home face1 face\123
Matt 1 878 home face2 face\345
Matt 1 878 home face3 face\678
Matt 2 879 home head1 head\123
Matt 2 879 home head2 head\345
Matt 2 879 home head3 head\678
DF3:
Address2 Hash
face\123 abc123
face\345 cde321
face\678 efg123
head\123 123efg
head\345 efg321
head\678 acd321
我正試圖結合3個dataframes成一個象下面這樣:
Name1 Name2 ID1 Address Own Name3 ID2 Name4 Address2 Hash
Matt John1 1 878 home Deal Jill 0 face1 face\123 abc123
Matt John1 1 878 home Deal Jill 0 face2 face\345 cde321
Matt John1 1 878 home Deal Jill 0 face3 face\678 efg123
Matt John2 2 879 home Dael Jack 1 head1 head\123 123efg
Matt John2 2 879 home Dael Jack 1 head2 head\345 efg321
Matt John2 2 879 home Dael Jack 1 head3 head\678 acd321
DF1之間和DF2關鍵是到ID1 DF2之間和DF3關鍵是地址2
非常感謝您的幫助。
你不就是在這裏合併列交叉嗎? 'df1.merge(DF2).merge(DF3)'? – miradulo