Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 将多个列表转换为列(或表格)格式_Python_List - Fatal编程技术网

Python 将多个列表转换为列(或表格)格式

Python 将多个列表转换为列(或表格)格式,python,list,Python,List,我有如下多个列表:-(我正在使用Python) 我需要将其更改为列格式,如下所示:- m0 275 336 m1 334 776 我已经尝试了很多东西,但都没有出现。我该如何处理这个问题?如果您不受限制使用其他软件包,请尝试- import numpy as np import pandas as pd mat = np.asarray([l1, l2]) df = pd.DataFrame(mat) >>> df 0

我有如下多个列表:-(我正在使用Python)

我需要将其更改为列格式,如下所示:-

m0  275  336
m1  334  776

我已经尝试了很多东西,但都没有出现。我该如何处理这个问题?

如果您不受限制使用其他软件包,请尝试-

    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
你也可以试试-

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

请将您的代码片段添加到“很多东西”的真实PythonOut中,请分享一个您最惊讶的代码片段,它不起作用,人们将能够帮助改进它或解释问题。您想要一个熊猫数据框架吗?展示了如何做到这一点,尽管问题有点不同。
>>> df_no_indices = df.to_string(index=False)
>>> print(df_no_indices)
  0    1    2
 mo  275  336
 m1  334  776