Groupby-apply и groupby-sum должны сделать трюк:
Данные
df = pd.DataFrame([['cake', 'wedding', 2],
['chairs', 'wedding', 2],
['chairs', 'funeral', 3]], columns = ['Product', 'occasion', 'count'])
Решение
df2 = df.groupby('Product')['occasion'].apply(lambda x: "|".join(x)).reset_index().set_index('Product')
df2['count'] = df.groupby('Product')['count'].sum()
Выход
print(df2.to_string())
occasion count
Product
cake wedding 2
chairs wedding|funeral 5