简体   繁体   English

我如何确定一列不应该等于零

[英]How do I determine a column is equal to zero when it's not supposed to be

How can I write in python if/else statement for if column A value ranges between 5 and 15, then column B should not be equal to 0?如果列 A 的值介于 5 和 15 之间,那么如何在 python 中编写 if/else 语句,那么列 B 不应该等于 0?

if (5 < columnA < 15):
    if b != 0:
        return True
    else:
        return False
else:
    return True

This will check if columnA is in the range, if it's not, b doesn't matter and will return True .这将检查columnA是否在范围内,如果不在范围内, b无关紧要并返回True
If columnA is in the range, will check if b is 0 .如果columnA在范围内,将检查b是否为0 If it's 0 will return False , if b it's not 0 , it will return True如果是0会返回False ,如果b不是0会返回True

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何计算列值等于NaN或零? - How can I count if column value is equal to NaN or zero? 我如何使此代码执行应做的工作? - How can i make this code do what it's supposed to do? 如何确定类不相等 - How to determine that classes do not equal each other 如何检查 pandas dataframe 列中的所有值是否相等? - How do I check if all values in a column of a pandas dataframe are equal? 如何将列表值与不完全相等的数据框列进行比较? - How do I compare list values to a dataframe column that are not exactly equal? 如何添加两个python词典,使不等于的思想变为零? - How do I add two python dictionaries such that the not equal thinks become zero? 如何从 numpy 数组中删除在另一个数组中等于零的所有元素? - How do I remove all elements from a numpy array that are equal to zero in another array? 如何确定熊猫列中值的“稳定性”? - how can I determine a value's 'stability' in a pandas' column? 怎么做 &#39;?&#39; 等于一个数字,所以当我浏览一个列表时。 它会将其计为零。 (Python) - How to make '?' equal a number, so when i go through a list. It will count it as a zero. (Python) 我该如何解决一个函数,该函数应该仅将0移到列表的末尾,但还要移动False值? - How do I fix a problem with a function that is supposed to only move 0's to the end of the list, but moves False values as well?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM