Python Forum
How to aggregate rows with same column - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: How to aggregate rows with same column (/thread-11433.html)



How to aggregate rows with same column - Leoni - Jul-08-2018

Hi all,

From this input:

google.com, hello, blublu
google.com, hello, blabla
google.com, nothello, bleble
facebook.com, hi, blabla
facebook.com, hey, bleble

how can i generate this output:

google.com | hello, hello, nothello | blublu, blabla, bleble
facebook.com | hi, hey | blabla, bleble

It's important to not delete same values (i.e. "hello, hello" in the second column of the output must remains because each input's rows is an identificative and when i see the output i would understand from which input come from).

How could i do that?

Thanks
Alex


RE: How to aggregate rows with same column - Larz60+ - Jul-08-2018

what are your python expertise?
if you can't start, I would suggest the starting point be a python tutorial.
and start with the latest version of python 3.7.0.
there are many tutorials available, run google and search for 'best python tutorials'
one of my favorites is: https://www.python-course.eu/