If语句在Excel数据中的特定单元格上



我试图在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语句不工作,因为没有输出任何内容。

我不知道为什么会发生这种情况,我将感谢任何提示。谢谢!

Vinzent提供的答案

check=df.iat[1,13]  #I am reading the value of the cell
if not pd.isna(check):
print("cell is not empty")

相关内容

最新更新