检查单个单元格的值是否为Pandas中的NaN [英] Check if single cell value is NaN in Pandas
本文介绍了检查单个单元格的值是否为Pandas中的NaN的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只想检查Pandas系列中的单个单元格是否为空,即检查值是否为NaN
.
I just want to check if a single cell in Pandas series is null or not i.e. to check if a value is NaN
.
所有其他答案适用于序列和数组,但不适用于单个值.
All other answers are for series and arrays, but not for single value.
我尝试了pandas.notnull
,pandas.isnull
,numpy.isnan
.是否只有一个单一值的解决方案?
I have tried pandas.notnull
, pandas.isnull
, numpy.isnan
. Is there a solution for a single value only?
推荐答案
尝试一下:
import pandas as pd
import numpy as np
from pandas import *
>>> L = [4, nan ,6]
>>> df = Series(L)
>>> df
0 4
1 NaN
2 6
>>> if(pd.isnull(df[1])):
print "Found"
Found
>>> if(np.isnan(df[1])):
print "Found"
Found
这篇关于检查单个单元格的值是否为Pandas中的NaN的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文