小编use*_*849的帖子

将python数据帧转换为列表

我有一个包含多列的Python dataFrame.

  LogBlk    Page                                    BayFail       
  0          0                                 [0, 1, 8, 9]  
  1          16           [0, 1, 4, 5, 6, 8, 9, 12, 13, 14]  
  2          32           [0, 1, 4, 5, 6, 8, 9, 12, 13, 14]  
  3          48           [0, 1, 4, 5, 6, 8, 9, 12, 13, 14]  
Run Code Online (Sandbox Code Playgroud)

我想找到与LogBlk = 0和Page = 0相关联的BayFails.

df2 = df[ (df['Page'] == 16) & (df['LogBlk'] == 0) ]['BayFail']
Run Code Online (Sandbox Code Playgroud)

这将返回[0,1,8,9]

我想要做的是将此pandas.series转换为列表.有谁知道这是怎么做到的吗?

python python-2.7 python-3.x pandas

17
推荐指数
1
解决办法
8万
查看次数

标签 统计

pandas ×1

python ×1

python-2.7 ×1

python-3.x ×1