密钥错误: 'the label [False] is not in the [index]'



我有一个带有 2 级标头的数据帧,我有如下所示的代码。

我收到此错误: 键错误: "标签 [假] 不在 [索引] 中">

知道我该如何解决这个问题吗?

for row in range(len(data)):
    if (data.loc[row, ('City', 'A')] == 'Active') & (data.loc[row, ('Cost', 'A')==0]):
            data.loc[row, ('Cost', 'A')] = data.loc[row, ('Cost','B')]

试试这个

if (data.loc[row, ('City', 'A'(] == 'Active'(

& (data.loc[row, ('Cost', 'A'(]==0(

相关内容

最新更新