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

Need to get the specific data from a column and to transpose them to the rows using Python & Pandas

Help me to attain the output using Python and Pandas
Input:

Name1
Sn1
nois
gif
quip
Date
Dur
Res
Name2
Sn2
nois
on
quipe
Date
Dur
Res

Expected Output:

Name1   Sn1 nois    gif quip    Date    Dur Res
Name2   Sn2 nois    on  quipe   Date    Dur Res

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

>Solution :

Try with reshape

out = pd.DataFrame(df.values.reshape(-1,8))
Out[72]: 
       0    1     2    3      4     5    6    7
0  Name1  Sn1  nois  gif   quip  Date  Dur  Res
1  Name2  Sn2  nois   on  quipe  Date  Dur  Res
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