数据帧:
col1
[[0.43], [0.46], [1.0], [0.323]]
[[0.33], [0.66], [1.0], [0.3412]]
[[0.27], [0.42], [0.13], [0.332]]
我试图根据以下内容创建一列:col11
>;=的嵌套列表中是否有数字。5然后是“是”,否则是“否”
结果:
col1 col2
[[0.43], [0.46], [1.0], [0.323]] yes
[[0.33], [0.66], [1.0], [0.3412]] yes
[[0.27], [0.42], [0.13], [0.332]] no
最好有一个列,列中的数字在嵌套列表中的位置为>;=。5.对于上述df,这将是col3: 3,3,N/A
这样想:
for i in df.col1:
print(i)
if j in i >= .05:
print(i,"yes")
else:
print(i,"no")
你能行
将列表理解与}快,因为它在{}上短路
any
一起使用any
比{一些时间安排:
用
max
理解旁侧测试列表因此,
any
虽然不显著,但速度更快一个简单的
apply
就可以了输出
相关问题 更多 >
编程相关推荐