Concatenating rows

Hi Team

How do I concatenate certain rows in my input as shown below

Input -

Output -

Attaching excel sheet below -
Example.xlsx (9.5 KB)



Have a look below thread and follow the same steps.

1 Like

We have described here:

1 Like

Below is the solution in python

import pandas as pd
xls = pd.ExcelFile(r’File_Location.xlsx’)
df = pd.read_excel(xls, ‘Sheet2’)

df[‘subject’] = df.groupby([‘Name’])[‘subject’].transform(lambda x : ’ '.join(x))
df[‘Marks’] = df.groupby([‘Name’])[‘Marks’].transform(lambda x : ’ '.join(x))

df = df.drop_duplicates(subset=‘Name’)

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.