python-3.x - 如何在包含空列表的数据框中删除行?
问题描述
我创建了一个包含 3 列的数据框,第三列包含列表,我想在该单元格中删除包含空列表的行。
我试过了
df[df.numbers == []] and df[df.numbers == null]
but nothing works.
name country numbers
Lewis Spain [1,4,6]
Nora UK []
Andrew UK [3,5]
结果将是一个没有 Nora 行的数据框
解决方案
嗯检查bool
df[df.numbers.astype(bool)]
推荐阅读
- react-native - 导航生命周期 ReactNative
- microsoft-teams - Microsoft Teams 中的设置和策略之间的明确关系是什么?
- python - 如何使用 PyPDF2 选择 pdf 格式的单选按钮?
- android - Dagger 无法注入应用程序上下文
- mongoose - 之后如何在猫鼬文件上获得财产?
- python - Django - 重构项目和应用程序名称后没有迁移文件夹
- python - 如何计算无限数量的坐标输入的平均值?
- machine-learning - rapidminer中的逻辑回归最大似然
- ansible - 如果使用“when”,ansible jinja2 模板分隔符会失败
- azure - 与 Azure 密钥保管库集成的应用服务 - 阵列内的配置