Why doesn't python pandas use 3 digit logic?

I wonder why python pandas / numpy does not implement 3-digit logic (the so-called Łukasiewicz logic) with true, false and NA (e.g. R). I read ( https://www.oreilly.com/learning/handling-missing-data ) that this is somewhat due to the fact that pandas uses much more basic data types than R, for example. However, this is not entirely clear to me why in this case it is inevitable to have this strange behavior of logical operations with missing values.

Example.

import numpy as np
np.nan and False   # so far so good, we have False
np.nan or False    # again, good, we have nan
False and np.nan   # False, good
False or np.nan    # give nan, so again, it is correct
np.nan and True    # weird, this gives True, while it should give nan
True and np.nan    # nan, so it is correct, but switching order should not affect the result
np.nan or True     # gives nan, which is not correct, should be True
True or np.nan     # True so it is correct, again switching the arguments changes the result

So, the example shows that something very strange happens when comparing the values ​​of np.nanand True. So what is going on here?

. , , np.nan "" . - , ?

0
2

numpy , , python:

In [11]: bool(float('nan'))
Out[11]: True

In [12]: bool(np.NaN)
Out[12]: True

(NaN "".)

+1

or and.

or , True bool(value), False, .

and, , , True bool(value1) bool(value2)

0

Source: https://habr.com/ru/post/1683906/


All Articles