I have been struggling with this problem all week. I have two DataFrames as follows:
df1:
Account| ID | Name
--------------------------------------
B36363 | 2019001 | John
G47281 | 2019002;2018101 | Alice;Emma
H46291 | 2019001 | John
df2:
Account | Col_B | Col_C
-----------------------------
B36363-0 | text_b1 | text_c1
01_G47281 | text_b2 | text_c2
X_H46291 | text_b3 | text_c3
II_G47281 | text_b4 | text_C4
I want to merge these DataFrames on Account when df2.Account contains df1.Account (not the full match with a normal merge/join!)
Desired output:
df3:
Account | Col_B | Col_C | ID | Name
--------------------------------------------------------------
B36363-0 | text_b1 | text_c1 | 2019001 | John
01_G47281 | text_b2 | text_c3 | 2019002;2018101 | Alice;Emma
X_H46291 | text_b3 | text_c3 | 2019001 | John
II_G47281 | text_b4 | text_C4 | 2019002;2018101 | Alice;Emma
I have no sample code because I have no idea how to handle this. A normal merge/join goes well, but not if I want to use contains. Thank you very much in advance