I have two data frames in Python like the following
df1
CUSTOMER_KEY LAST_NAME FIRST_NAME
30 f2b6769129 97bb97bebc
46 ca0464878d e276539bc2
51 62f2905a7a 8dfabd6d61
57 21032ca3bc 1f7e5e0c6e
62 f7e7fdd8ce eb6cf4af99
64 f536998bbb 7fc39eacd1
80 6069198f63 d873a71620
99 0ba61a6f66 a6cf7af3eb
102 e8b579b776 c8048fd459
df2
CUSTOMER_KEY LAST_NAME FIRST_NAME
30 Arthur Anderson
46 Teresa Johns
51 Louise Hurwitz
57 Timothy Addy
62 Jeffery Wilson
64 Andres Tuller
80 Daniel Green
99 Frank Nader
102 Faith Young
I want to join these two data frames on Customer_key (which i can do in Merge) and later concatenate on few columns from the data frame to form a new string in the result data frame. From the below dataframes the result that i am looking is as follows
result_df
CUSTOMER_KEY LAST_NAME FIRST_NAME
30 Artf2b676 And97bb97
46 Terca0464 Johe27653
Basically, substring(last_name,1,4) in df2 and substring(last_name,1,6) in df1 and concatenate those into the new column. Similarly other columns.
How can i achieve this please.
Thanks and Regards
Bala