Handling of dtype bool is not straight-forward
See original GitHub issueI would expect a numpy array containing boolean values to react meaningful to “is True”
Reproducing code example:
import numpy as np
np.array([True])[0] is True
Out[3]: False
np.array([True])[0] == True
Out[4]: True
dtype evaluates to dtype(‘bool’).
I know that the dtype is not build-in anymore, and technically it does not “point to the same object” but I see no reason why numpy should not gracefully handle that situation and do what the user obviously wants to do there.
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Pandas read csv infer only bool - Stack Overflow
I would like to use pandas. read_csv to infer only boolean types in the data. If I use dtypes=str , I do not...
Read more >DISCUSS: boolean dtype with missing value support #28778
Indexing with a BooleanArray with no missing values. Indexing a dtype that supports missing values (datetime, timedelta, string, object, Int64, ...
Read more >Caveats and Gotchas — pandas 0.19.2 documentation
A masked array is an array of data with an associated boolean mask denoting whether each value should be considered NA or not....
Read more >When To Use the Nullable NaN - Towards Data Science
Takeaway: When the source column contains null values or non-boolean values such as floats like 1.0, applying the Pandas 'bool' dtype may ...
Read more >NumPy 1.20.0 Release Notes
numpy.bool. bool. numpy.bool_. numpy.int. int. numpy.int_ (default), numpy.int64 , or numpy. ... NumPy dtypes are not direct instances of np.dtype anymore.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
More information on integer caching in python, which is obviously by design.
The
is
operator in python simply means “these are the same instances of the object” - the language makes no guarantees about whether two integers are identical or different instances. I don’t think there’s anything to report here.The behavior is intentional and will not be changed. If you want to cast to Python object, do