-2

I have multiple lists as follows:- (I am using Python)

l1 = [mo 275 336]
l2 = [m1 334 776]

I need to change it into column format as belows:-

m0  275  336
m1  334  776

I have tried a lot of things but it's not coming up. How do I approach this?

wjandrea
  • 28,235
  • 9
  • 60
  • 81
  • 1
    Please add your code snippets in real Python – Dani Mesejo Dec 11 '20 at 00:03
  • 1
    Out of "a lot of things", please share the one you were most surprised about that it didn't work, and people will be able to help improve it or explain the problem. – Grismar Dec 11 '20 at 00:11
  • Do you want a Pandas dataframe? [This answer](https://stackoverflow.com/a/35509134/4518341) shows how to do that, though the question's a bit different. – wjandrea Dec 11 '20 at 00:15

1 Answers1

1

If your are not constrained to use other packages, try-

    import numpy as np
    import pandas as pd
    mat = np.asarray([l1, l2])
    df = pd.DataFrame(mat)

>>> df
    0    1    2
0  mo  275  336
1  m1  334  776

you could also try-

>>> df_no_indices = df.to_string(index=False)
>>> print(df_no_indices)
  0    1    2
 mo  275  336
 m1  334  776