Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.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 Pd:将列表列转换为字符串列_Python - Fatal编程技术网

Python Pd:将列表列转换为字符串列

Python Pd:将列表列转换为字符串列,python,Python,我这里有一个数据框,看起来像这样(我还不能上传图像,所以我使用纯文本): 我想把它转换成: # name things1 things2 things3 things4 0 a d e f 1 b g f s w 2 c s 有没有什么方法可以让我干净利落地做这件事?我只是一个初学者,所以我不能理解太复杂的代码。非常感谢 您正在查找以下行: df2 = pd.concat([d

我这里有一个数据框,看起来像这样(我还不能上传图像,所以我使用纯文本):

我想把它转换成:

#  name  things1  things2  things3 things4
0    a     d       e         f
1    b     g       f         s       w
2    c     s

有没有什么方法可以让我干净利落地做这件事?我只是一个初学者,所以我不能理解太复杂的代码。非常感谢

您正在查找以下行:

df2 = pd.concat([df.name, df.things.apply(pd.Series)], axis=1)
下面是一个可复制的示例(相同的转换,但有完整的代码,以便您可以重新介绍和理解它):


你在用熊猫包吗?这能回答你的问题吗?
df2 = pd.concat([df.name, df.things.apply(pd.Series)], axis=1)
# Create dataset
import pandas as pd
import numpy as np

df = pd.DataFrame(np.array([["a", "b"],[["d", "e", "f"],["d", "e", "f"]]])).T
df.columns = ["value", "list"]

# Apply transformation
df2 = pd.concat([df.value, df.liste.apply(pd.Series)], axis=1)