Error: The truth value of a Series is ambiguous - Python pandas

后端 未结 3 1596
时光取名叫无心
时光取名叫无心 2020-12-06 17:58

I know this question has been asked before, however, when I am trying to do an if statement and I am getting an error. I looked at this link , but did not help

3条回答
  •  不知归路
    2020-12-06 18:22

    the comparison returns a range of values, you need to limit it either by any() or all(), for example,

         if((df[col] == ' this is any string or list').any()):
           return(df.loc[df[col] == temp].index.values.astype(int)[0])
    

提交回复
热议问题