根据另一行的内容打印熊猫数据框的内容?

时间:2019-06-27 19:26:32

标签: python-3.x pandas

当前,我有一个具有以下内容的Pandas数据框

                 0  1    2      3
3.7811269080692846  0    1  False
6.5515931524621935  0    2  False
3.7698643400208622  1    2  False
6.326990562771453   1    3  False
3.809210658069484   2    3  False
6.575605035089512   2    4  False
6.609225000701518   2    18 True
3.7931060673120025  3    4  False
6.84073676339154    3    5  False
5.0170858504448494  3    18 True
4.636572859208401   3    19 False
6.914299522130306   3    20 True

我试图基于列1的内容访问其他列的内容。例如,理想情况下,只要列1包含值0,我都希望打印列0和列3。使用以下代码

indices = []
for index, value in final_contacts[1]:
    if value == 0:
        indices.append(index)
        for i in indices:
            print(final_contacts[3][i])
            print(final_contacts[0][i])

但是我遇到无法解压缩不可迭代的int对象错误。理想的输出是

False
False
3.7811269080692846
6.5515931524621935

0 个答案:

没有答案
相关问题