pandas -过滤无值 [英] Pandas - Filtering None Values

查看:60
本文介绍了 pandas -过滤无值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Pandas探索一些数据集.我有这个数据框:

I'm using Pandas to explore some datasets. I have this dataframe:

我要排除任何具有城市价值的行.所以我尝试了:

I want to exclude any row that has a city value. So I've tried:

new_df = all_df[(all_df["City"] == "None") ]
new_df

但是随后我得到一个空的数据框:

But then I got an empty dataframe:

只要我使用None以外的任何值,它都可以工作.知道如何过滤此数据框吗?

It works whenever I use any value other than None. Any idea how to filter this dataframe?

推荐答案

考虑使用isnull()查找丢失的值

all_df[all_df['City'].isnull()]

这篇关于 pandas -过滤无值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆