python - 选择 Col1 "isnull" & Col2 "notnull" 的行
问题描述
我想选择 col1 中的值为 null 并且 col2 中的值不为 null 的行
col1 col2
423 NaN
NaN 291
391 102
期望的输出
col1 col2
NaN 291
解决方案
使用pandas loc
:
df.loc[(df['col1'].isna()) & (~df['col2'].isna())]
推荐阅读
- python - Python Selenium --user-data-dir 选项错误:无法删除旧的 devtools 端口文件
- sql-server - 在同一个查询中使用 JOIN 和 OFFSET
- python-3.x - Windows上的HDF5充气错误
- gmail-api - 创建发布者主题时“用户无权执行此操作”
- android - 谷歌登录在华为的“Mate 9”中无法使用,但在任何其他设备上都可以正常使用
- json - 如何在 Go 中构建递归的结构切片?
- python - 对两个子查询的总和进行排序
- .net - Visual Studio 中缺少 package.appxmanifest
- powershell - 当引用打开时 powershell 脚本遇到 EOF 会发生什么?
- python - LateX 文本渲染不适用于 Matplotlib