0

I want to convert 3 rows into one row. My file has every row enumerated as shown here

============================================================================
 1   148637.9532    9.24549529  3.130977E+08  0.000000E+00  3.409656E+34
    8.214303E+00  2.622976E+01  8.664373E+00  0.0000000000  0.000000E+00
    3.278447E+35 -9.999860E+00 -1.999885E+00 -3.053960E-01 -3.053960E-01
 2   126233.7576    9.25459571  3.098344E+08  5.000000E+04  1.736974E+34
    8.196269E+00  2.623452E+01  8.667948E+00  0.0000000000  0.000000E+00
    1.887412E+35 -9.999860E+00 -1.999885E+00 -3.053960E-01 -3.053960E-01
 3   113241.7873    9.25990287  3.079471E+08  1.000000E+05  1.111248E+34
    8.182727E+00  2.623774E+01  8.670373E+00  0.0000000000  0.000000E+00
    1.262693E+35 -9.999860E+00 -1.999885E+00 -3.053960E-01 -3.053960E-01
 4   104846.8783    9.26340008  3.067097E+08  1.500000E+05  8.100445E+33

As you can see every 3 rows is 1 row.

The problem comes when I try and read this using pandas, because it only recognise one column. I have tried to fix this by using

df = df.reset_index(drop=False)

but it only generate new index. Any help with this is very welcome! thanks!

Elissa
  • 1
  • `df.explode('col').explode('col')`? –  Dec 15 '21 at 05:47
  • Welcome to Stackoverflow. Please take the time to read this post on [how to provide a great pandas example](http://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) as well as how to provide a [minimal, complete, and verifiable example](http://stackoverflow.com/help/mcve) and revise your question accordingly. These tips on [how to ask a good question](http://stackoverflow.com/help/how-to-ask) may also be useful. – jezrael Dec 15 '21 at 05:52

0 Answers0