Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

unable to concat the output for multiple rows

I have a dataframe which is like below

enter image description here

If i write a code like below

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

df.iloc[0]

enter image description here

And if i write code like below

df.iloc[3]

enter image description here

I want to concat all the df.iloc[0], df.iloc1, df.iloc2 untill whatever the max rows are are present. But with the help of for loop i’m unable to. Can anyone help me with this?

>Solution :

Use concat with comprehension:

df1 = pd.concat((df.loc[i] for i in df.index))

Or:

df1 = pd.concat((df.iloc[i] for i in range(len(df.index))))
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading