python - Python Pandas - notnull() 和 ~notnull() 不是互斥的
问题描述
当我运行以下代码时:
maintenance_items['Last order'][maintenance_items['Last order'].notnull()].count()
我得到的答案是 16522(19313 中)。这似乎是正确的。但是,如果我使用以下任何代码来检查相反的情况:
maintenance_items['Last order'][~maintenance_items['Last order'].notnull()].count()
或者
maintenance_items['Last order'][maintenance_items['Last order'].isnull()].count()
或者
maintenance_items['Last order'][maintenance_items['Last order'].isna()].count()
我得到的答案是 0(19313 中)。我期待 2791(19313 减去 16522)。为什么上面的 notnull() 和相反的语句不相互排斥有充分的理由吗?
解决方案
推荐阅读
- laravel-5.7 - Maatwebsite 3.1 导入,队列不起作用
- makefile - 基于 ifeq 测试的条件包含子 Makefile
- sql-server - 如何将日期格式从 yyyy-mm-dd 更改为 yyyymm?
- php - 以 html 形式更新一个表值,这些值依赖于另一个表
- python - 比较添加、删除、修改的 2 个 CSV 记录字段值
- python - 我的 Python if-else 语句不起作用,我不知道为什么
- ios - 如果不影响动画,则立即完成
- angular - 带有Angular js 6的电子,动态图像不在同一版本中显示
- vuejs2 - 如何在 Vue 的道具验证器中访问“this”
- java - 有什么方法可以在 1970 年之前转换 java 中的日期?