Vertical concatenation in a df based on column value_python Is there any way to concatenate vertically a specific column from my df (concat1), considering/filtering values from another column (col_value)?
My df looks like this:
col_value         concat1    
data1             x;y;z    
data1             d;f;h
data1             p;c;j
data2             s;k;a 
data3             a;w;q
data2             o;i;s 
data3             e;q;j
data4             d;f;n
data4             q;f;k

Expected output:
col_value         vertical_concat

data1             x;y;z;d;f;h;p;c;j    
data1             x;y;z;d;f;h;p;c;j
data1             x;y;z;d;f;h;p;c;j
data2             s;k;a;o;i;s
data3             a;w;q;e;q;j
data2             s;k;a;o;i;s
data3             a;w;q;e;q;j
data4             d;f;n;q;f;k
data4             d;f;n;q;f;k

Many thanks in advance
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: