close

How to combine multiple rows into a single row with pandas

Hello Guys, How are you all? Hope You all Are Fine. Today We Are Going To learn about How to combine multiple rows into a single row with pandas in Python. So Here I am Explain to you all the possible Methods here.

Without wasting your time, Let’s start This Article.

Table of Contents

How to combine multiple rows into a single row with pandas?

  1. How to combine multiple rows into a single row with pandas?

    print df.groupby('value')['tempx'].apply(' '.join).reset_index() value tempx 0 1.5 picture1 picture555 picture255 picture365 pict...

  2. combine multiple rows into a single row with pandas

    print df.groupby('value')['tempx'].apply(' '.join).reset_index() value tempx 0 1.5 picture1 picture555 picture255 picture365 pict...

Method 1

You can use groupby and apply function join :

print df.groupby('value')['tempx'].apply(' '.join).reset_index()
   value                                              tempx
0    1.5  picture1 picture555 picture255 picture365 pict...

Summery

It’s all About this issue. Hope all Methods helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which Method worked for you? Thank You.

Also, Read