Merging 2 pandas dataframes on key with duplicates but do not want it to result in two lines
Without a reproducible exmple is difficult but I would go with something like this:
df = pd.DataFrame({&quot;key_column&quot;:[&quot;key1&quot;,&quot;key1&quot;,&quot;key2&quot;,&quot;key3&quot;],&quot;name_column&quot;:[&quot;NAME1&quot;,&quot;NAME2&quot;,&quot;NAME3&quot;,&quot;NAME4&quot;]})

df.groupby(&quot;key_column&quot;).name_column.apply(lambda x: &quot;/&quot;.join(list(x)))

Result:
key_column
key1    NAME1/NAME2
key2          NAME3
key3          NAME4
Name: name_column, dtype: object