python - Excel 数据中特定单元格的 if 语句
问题描述
我正在尝试根据 excel 数据框中的单元格值运行特定的脚本行。如果特定单元格不为空,我基本上想进行计算。为此,我使用了以下代码:
check=df.iat[1,13] #I am reading the value of the cell
if check is not (None, "[nan]"):
print("cell is not empty")
当我打印检查的值(单元格值)时,我得到'nan'。但是,if 语句不起作用,因为没有打印任何内容。
我不确定为什么会发生这种情况,我将不胜感激任何提示。谢谢!
解决方案
文森特提供的答案
check=df.iat[1,13] #I am reading the value of the cell
if not pd.isna(check):
print("cell is not empty")
推荐阅读
- java - 如何从覆盖方法java调用值?
- java - 在具有身份验证的代理后面使用 Azure EventHub
- python - 在 Django StaticLiveServerTestCase 中提交使用 Intercooler 的表单
- python-3.x - 在python中使用opencv按面积查找第二大轮廓及其内部轮廓
- python - Try/catch 块显示 TypeError: until_not() missing 1 required positional argument: 'method'
- r - 将嵌套列表中的元素传递给 renderUI
- c# - 在 C# 中异步等待事件
- json - 从带有分隔符的字符串中的 json 文件中获取值
- python - TensorFlow FailedPreconditionError:迭代器尚未初始化
- android - 在 Android Studio 中更改选中的单选按钮颜色