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

Append all columns of dataframe to a new dataframe

I want to append all columns of a dataframe to a new dataframe with single column.

My Current Dataframe:

|**namelist1**| **namelist2** |  **namelist3** |and so on
|khalid       |  sabbir       | liton          |
|tamim        |  sakib        | tawhid         |
|taskin       |  santo        | naim           |

Expected Dataframe:

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

**namelistall**
khalid      
sabbir     
liton
tamim       
sakib      
tawhid
taskin      
santo      
naim

>Solution :

Use numpy.ravel with DataFrame constructor:

df = pd.DataFrame({'namelistall': np.ravel(df.to_numpy())})
print (df)
  namelistall
0      khalid
1      sabbir
2       liton
3       tamim
4       sakib
5      tawhid
6      taskin
7       santo
8        naim
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