我正在尝试将 Pandas 数据框列表列转换为字符串。但没有得到预期的输出。谁能帮我解决这个问题:
数据帧:df
A B
0 [] ['good']
1 [] ['one','two','three']
2 [] []
3 [] []
4 [] []
5 [] []
6 [] ['yes']
7 [] []
8 [] []
9 [] []
10 [] ['dog','cat']
11 [] []
12 [] []
13 [] []
14 [] ['low','mid','high']
代码行:
df['A'] = df['A'].astype(str)
df['B'] = df['B'].astype(str)
预期输出:
A B
0 good
1 one,two,three
2
3
4
5
6 yes
7
8
9
10 dog,cat
11
12
13
14 low,mid,high