gpt4 book ai didi

python - 将列表列表转换为无法分隔列的 pandas

转载 作者:行者123 更新时间:2023-12-01 02:39:46 27 4
gpt4 key购买 nike

我正在尝试将列表列表转换为 pandas 数据框。这是列表:

[[array([[u'2017-08-22', u'xxx BRAZIL', u'channel_name1',
u'SEM xx-xx', u'sessions', u'-0.413447782546', u'-1156',
u'1640.0', u'2796.0']],
dtype='<U32')], [array([[u'2017-08-22', u'xxx BRAZIL', u'channel_name1',
u'xx-xx', u'sessions', u'0.0180327868852', u'11',
u'621.0', u'610.0']],
dtype='<U32')], [array([[u'2017-08-22', u'xxx BRAZIL', u'channel_name1',
u'xx-xxx', u'sessions', u'-0.0529421060949',
u'-1005', u'17978.0', u'18983.0']],
dtype='<U32')], [array([[u'2017-08-22', u'xxx BRAZIL', u'channel_name1',
u'xx-xx', u'sessions', u'-0.150395778364', u'-114',
u'644.0', u'758.0']],
...

这是我的代码:

df = DataFrame(outliers_list)

但我将其作为输出:

                                                   0
0 [[2017-08-22, XXX, channel_name1, RE...
1 [[2017-08-22, xxx, channel_name1, CR...
2 [[2017-08-22, xxx, channel_name1, DI...
3 [[2017-08-22, xxx, channel_name1, AF...
4 [[2017-08-22, xxx, channel_name1, RE...
5 [[2017-08-22, xxx, channel_name1, CR...
6 [[2017-08-22, xxx, channel_name1, DI...
7 [[2017-08-22, xxx, channel_name1, RE...
8 [[2017-08-22, xxx, channel_name1, CR...
9 [[2017-08-22, xxx, channel_name1, DI...

我将整行放入一列中。如何分隔列?

最佳答案

尝试这样的事情:

df = pd.DataFrame([a[0][0] for a in outliers_list])

关于python - 将列表列表转换为无法分隔列的 pandas,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45844611/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com