Python value comparison, Np.nan is Np.nan but Np.nan! = Np.nan, pandas single data frame value to Judge Nan

Source: Internet
Author: User

Pandas in Dataframe,series have IsNull () method, and the data frame is not, use will be error: Attributeerror: ' Float ' object has no attribute ' IsNull '

How to tell if a single box is Np.nan

Python's general judgment, = =, and is, which is valid for none

None is None
OUT[49]: True

none = = None
OUT[50]: True

And yes, Np.nan, can only use is

Da1pd.ix[6000996,u ' team '] = = Np.nan
OUT[41]: False

Da1pd.ix[6000996,u ' team '] is Np.nan

OUT[42]: True

Np.nan! = Np.nan
OUT[43]: True

Np.nan is not none.

None = = Np.nan
OUT[46]: False

none!= Np.nan
OUT[47]: True

None is Np.nan
OUT[48]: False

This is related to the method of judging the IS and = =, whether it is the same object, such as a constant, a constant string

1 is 1
OUT[51]: True

and ' = = ' is the value judgment, the value of two variables is equal.

U = 156

v = 156

U is V
OUT[58]: True

#因为, Python, a reference to assigning a value to a variable, the default is the address, so the same object is assigned, and the same object

U = 156.0

U is V
OUT[60]: False

U = = V
OUT[61]: True

# An assignment integer that does not point to an object when it is assigned a floating-point number. Just the same value.

Back to the beginning, Np.nan should be no value, so can not be judged, only with the object reference to judge, and none has a null value, so it is also possible to determine the value.

Python value comparison, Np.nan is Np.nan but Np.nan! = Np.nan, pandas single data frame value to Judge Nan

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.