Convert 2nd column values to rows when column 1 is the same name

Craigc3814

Board Regular
Joined
Mar 7, 2016
Messages
217
I have 2 columns

Column 1 is the name of a street and that street name is repeated for each task that was completed on the street. I want to group the street name so that there is only 1 line but a new column for each task

10th street Repair pothole
10th street New Stop Sign
10th street New curb
11th street Repair Pothole
11th street Add Stoplight

so the data would look like this when complete

10th street Repair pothole New stop sign new curb
11th street Repair pothole Add stoplight

Is this done with a modulo column? I cannot seem to remember how I figured it out in the past.
 
yes, but this depends on your data source. pandas supports various data sources you can build a dataframe from

I have a large excel spreadsheet that is generated from a python script containing data in this format:

Code:
[TABLE="width: 1301"]
<tbody>[TR]
[TD]GUID[/TD]
[TD]Chemical[/TD]
[TD]Association[/TD]
[TD]Term[/TD]
[/TR]
[TR]
[TD]{2EFD7D98-C03D-4821-B43F-BC1DBAD7F6B8}[/TD]
[TD](1,1-Dimethylethyl)benzaldehyde[/TD]
[TD]exactMatch[/TD]
[TD]tert-Butylbenzaldehyde :- {(1,1-Dimethylethyl)benzaldehyde}[/TD]
[/TR]
[TR]
[TD]{2EFD7D98-C03D-4821-B43F-BC1DBAD7F6B8}[/TD]
[TD](1,1-Dimethylethyl)benzaldehyde[/TD]
[TD]exactMatch[/TD]
[TD]tert-Butylbenzaldehyde[/TD]
[/TR]
[TR]
[TD]{09114BCC-72B9-4A86-A18C-5C60304C4944}[/TD]
[TD](1,1-Dimethylethyl)benzene[/TD]
[TD]exactMatch[/TD]
[TD]tert-Butylbenzene[/TD]
[/TR]
[TR]
[TD]{09114BCC-72B9-4A86-A18C-5C60304C4944}[/TD]
[TD](1,1-Dimethylethyl)benzene[/TD]
[TD]exactMatch[/TD]
[TD]tert-Butylbenzene :- {(1,1-Dimethylethyl)benzene}[/TD]
[/TR]
</tbody>[/TABLE]

But I am wanting to represent this data like this:

Code:
[TABLE="width: 1051"]
<tbody>[TR]
[TD]GUID[/TD]
[TD]Chemical[/TD]
[TD]Association[/TD]
[TD]Term[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]{2EFD7D98-C03D-4821-B43F-BC1DBAD7F6B8}[/TD]
[TD](1,1-Dimethylethyl)benzaldehyde[/TD]
[TD]exactMatch[/TD]
[TD]tert-Butylbenzaldehyde :- {(1,1-Dimethylethyl)benzaldehyde}[/TD]
[TD]tert-Butylbenzaldehyde[/TD]
[/TR]
[TR]
[TD]{09114BCC-72B9-4A86-A18C-5C60304C4944}[/TD]
[TD](1,1-Dimethylethyl)benzene[/TD]
[TD]exactMatch[/TD]
[TD]tert-Butylbenzene[/TD]
[TD]tert-Butylbenzene :- {(1,1-Dimethylethyl)benzene}[/TD]
[/TR]
</tbody>[/TABLE]

Is there a way to do this with pandas ?
Sorry I am fairly new to python programming
Many thanks
 
Upvote 0

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

Forum statistics

Threads
1,214,792
Messages
6,121,612
Members
449,038
Latest member
apwr

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top