gpt4 book ai didi

python - 过滤 df 列中出现 nan 的行

转载 作者:太空宇宙 更新时间:2023-11-03 15:05:02 24 4
gpt4 key购买 nike

我有一个包含很多行的 df。

             Price   Time     Place
A 5.1 11.30 germany
B 4.1 08.30 lebannon
...
DY 7.49 01.15 italy
DZ 2.13 02.35 england

如何过滤 df 以获取 Price 列具有 Nan 的行 值?

到目前为止我已经尝试过

df[~df['Price'].str.isnumeric()]

但没有成功。

所需的输出将是这样的:

             Price   Time     Place
AS Nan 11.30 germany
BJ Nan 08.30 lebannon

最佳答案

使用isnull

df[df.Price.isnull()]

您还可以使用np.isnan

df[np.isnan(df.Price.values)]

关于python - 过滤 df 列中出现 nan 的行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44737300/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com