Presenting multiline data into single line

All other Source.Python topics and issues.
aaronbuhu
Junior Member
Posts: 1
Joined: Mon Aug 02, 2021 2:49 pm

Presenting multiline data into single line

Postby aaronbuhu » Mon Aug 02, 2021 2:53 pm

Hi,

I need some help with formatting the data within my excel files.

I have an excel report that includes multiple lines of data for the same unique id which I wish to transform it into a more readable form.

For example:

Unique ID Timestamp Method Type Transaction Details [-] [+] Gross Amount
6606521 2021-06-01 10:42:00 Online Deposits Deposit 50 50
6606521 2021-06-01 10:42:00 Online Deposits Variable Commission 1.6
6606521 2021-06-01 10:42:00 Online Deposits Fixed Commission 0.29

Instead of the above, I wish to create a dataframe with 3 new columns (Variable Commission, Fixed Commission, Other Commission) that would list all information in one line.

Unique ID Timestamp Method Type Transaction Details Gross Amount Variable Commission Fixed Commission Other Commission Net Amount
6606521 2021-06-01 10:42:00 Online Deposits Deposit 50 1.6 0.29 0 48.11

groupby-example.PNG
groupby-example.PNG (37.38 KiB) Viewed 3395 times


How can I convert the original dataframe into this new format? I tried the groupby function but I could not get it to work.

Any feedback is greatly appreciated.

Thanks for your help! I am new to this forum and looking forward to learning a lot from here.

Aaron

Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 27 guests