【发布时间】:2021-12-05 14:04:26
【问题描述】:
我正在尝试根据 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")
当我打印 check 的值(单元格值)时,我得到“nan”。但是,if 语句不起作用,因为没有打印任何内容。
我不确定为什么会发生这种情况,我会感谢任何提示。谢谢!
【问题讨论】:
-
改成
if not pd.isna(check): -
干杯 Vinzent,这确实有效!我不知道 .insa,非常有帮助!
-
知道我的脚本为什么不起作用吗?
-
请您回答这个问题,我会接受解决方案