I am still new with python could you pleas help me with this
i have this excel sheet
and i want it to be like this
Asked
Active
Viewed 26 times
0
-
Here is a thread that you can refer: https://stackoverflow.com/questions/36271413/pandas-merge-nearly-duplicate-rows-based-on-column-value – Pratik Joshi May 25 '20 at 15:31
2 Answers
0
You can convert the csv data to a panda dataframe like this:
import pandas as pd
df = pd.read_csv("Input.csv")
Then do the data manipulation as such:
df = df.groupby(['Name'])['Training'].apply(', '.join).reset_index()
Finally, create an output csv file:
df.to_csv('Output.csv', sep='\t')

Pratik Joshi
- 389
- 4
- 13
0
You could use pandas for creating a DataFrame
to manipulate the excel sheet information. First, load the file using the function read_excel
(this creates a DataFrame
), and then use the function groupby
and apply
to concatenate the strings.
import pandas as pd
# Read the Excel File
df = pd.read_excel('tmp.xlsx')
# Group by the column(s) that you need.
# Finally, use the apply function to arrange the data
df.groupby(['Name'])['Training'].apply(','.join).reset_index( )

scf.12
- 58
- 1
- 6