79270959

Date: 2024-12-11 08:21:18
Score: 0.5
Natty:
Report link

The following values are considered false:

  • None
  • False
  • zero of any numeric type, for example, 0, 0L, 0.0, 0j.
  • any empty sequence, for example, '', (), [].
  • any empty mapping, for example, {}.
  • instances of user-defined classes, if the class defines a nonzero() or len() method, when that method returns the integer zero or bool value False. 1 All other values are considered true — so objects of many types are always true.

Source: https://docs.python.org/2/library/stdtypes.html#truth-value-testing

So by these conventions None is False and np.nan is True.


Boolean dtype implements Kleene Logic (sometimes called three-value logic).

Source: https://pandas.pydata.org/docs/user_guide/boolean.html

For example, True | NA gives True because NA can be True or False and in both case the OR operation (|) will result to True because we have at least one True. Similarly, False | NA gives NA because we don't know if there is one True.

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (0.5):
Posted by: rehaqds