One - One Code All

Blog Content

pandas判断dataframe为空

Python 统计学-科学计算   2010-10-02 20:05:17

pandas 空值定义为numpy.nan

1.isnull
pd.isnull(df1) #df1是dataframe/series变量

2.empty
df.empty # 如果df为空,则 df.empty 返回 True,反之 返回False。,empty后面不要加()。

3.isnan,对单独的某个值判断,可以用 np.isnan()
np.isnan(df1.ix[0,3]) #对df1的第0行第3列判断




上一篇:六字诀
下一篇:unzip直接覆盖解压

The minute you think of giving up, think of the reason why you held on so long.