如何在Python中将pandas DataFrame与None进行比较?

如何在Python中将pandas DataFrame与None进行比较?,python,pandas,python-2.x,nonetype,Python,Pandas,Python 2.x,Nonetype,如何将pandas数据帧与None进行比较?我有一个构造函数,它接受参数_文件或参数_df中的一个,但决不能同时接受这两个参数 def __init__(self,copasi_file,row_to_insert=0,parameter_file=None,pandas_df=None): self.copasi_file=copasi_file self.parameter_file=parameter_file self.pandas_df=pandas_df

如何将pandas数据帧与
None
进行比较?我有一个构造函数,它接受
参数_文件
参数_df
中的一个,但决不能同时接受这两个参数

def __init__(self,copasi_file,row_to_insert=0,parameter_file=None,pandas_df=None):
    self.copasi_file=copasi_file
    self.parameter_file=parameter_file
    self.pandas_df=pandas_df      
但是,当我稍后尝试将
pandas_-df
None
进行比较时(即
self.pandas_-df
实际包含pandas数据帧时):

我得到以下类型错误:

  File "C:\Anaconda1\lib\site-packages\pandas\core\internals.py", line 885, in eval
    % repr(other))

TypeError: Could not compare [None] with block values

使用
不是

if self.pandas_df is not None:
    print 'Do stuff'
说:

应始终使用
is
is not
来比较像
None
这样的单例,而不要使用相等运算符

还有一个很好的理由

if self.pandas_df is not None:
    print 'Do stuff'