Vertical concatenation in a df based on column value_python
Try:
a = [&quot;data1&quot;      
,&quot;data1&quot;         
,&quot;data1&quot;         
,&quot;data2&quot;         
,&quot;data3&quot;         
,&quot;data2&quot;         
,&quot;data3&quot;         
,&quot;data4&quot;         
,&quot;data4&quot;]     

b = [&quot;x;y;z&quot;  
    ,&quot;d;f;h&quot;
    ,&quot;p;c;j&quot;
    ,&quot;s;k;a&quot;
    ,&quot;a;w;q&quot;
    ,&quot;o;i;s&quot;
    ,&quot;e;q;j&quot;
    ,&quot;d;f;n&quot;
    ,&quot;q;f;k&quot;]

e = pd.DataFrame({&quot;col_value&quot;:a,&quot;concat1&quot;:b})


e[&quot;vertical_concat&quot;] = e.groupby(&quot;col_value&quot;).transform(lambda x: &quot;;&quot;.join(x.unique()))

Output: