Skip to content

Commit d7ce57e

Browse files
simonjayhawkinsmeeseeksmachine
authored andcommittedJan 7, 2021
Backport PR pandas-dev#39019: DOC: np.bool -> np.bool_
1 parent 3dd9561 commit d7ce57e

File tree

5 files changed

+9
-4
lines changed

5 files changed

+9
-4
lines changed
 

‎.pre-commit-config.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,11 @@ repos:
144144
\#\ type:\s?ignore(?!\[)
145145
language: pygrep
146146
types: [python]
147+
- id: np-bool
148+
name: Check for use of np.bool instead of np.bool_
149+
entry: np\.bool[^_8]
150+
language: pygrep
151+
types_or: [python, cython, rst]
147152
- id: no-os-remove
148153
name: Check code for instances of os.remove
149154
entry: os\.remove

‎asv_bench/benchmarks/groupby.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ class TransformBools:
625625
def setup(self):
626626
N = 120000
627627
transition_points = np.sort(np.random.choice(np.arange(N), 1400))
628-
transitions = np.zeros(N, dtype=np.bool)
628+
transitions = np.zeros(N, dtype=np.bool_)
629629
transitions[transition_points] = True
630630
self.g = transitions.cumsum()
631631
self.df = DataFrame({"signal": np.random.rand(N)})

‎doc/source/user_guide/basics.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -2229,7 +2229,7 @@ Convert certain columns to a specific dtype by passing a dict to :meth:`~DataFra
22292229
.. ipython:: python
22302230
22312231
dft1 = pd.DataFrame({"a": [1, 0, 1], "b": [4, 5, 6], "c": [7, 8, 9]})
2232-
dft1 = dft1.astype({"a": np.bool, "c": np.float64})
2232+
dft1 = dft1.astype({"a": np.bool_, "c": np.float64})
22332233
dft1
22342234
dft1.dtypes
22352235

‎doc/source/user_guide/cookbook.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1406,7 +1406,7 @@ Often it's useful to obtain the lower (or upper) triangular form of a correlatio
14061406
df = pd.DataFrame(np.random.random(size=(100, 5)))
14071407
14081408
corr_mat = df.corr()
1409-
mask = np.tril(np.ones_like(corr_mat, dtype=np.bool), k=-1)
1409+
mask = np.tril(np.ones_like(corr_mat, dtype=np.bool_), k=-1)
14101410
14111411
corr_mat.where(mask)
14121412

‎pandas/tests/io/excel/test_writers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ def test_float_types(self, np_type, path):
492492

493493
@pytest.mark.parametrize("np_type", [np.bool8, np.bool_])
494494
def test_bool_types(self, np_type, path):
495-
# Test np.bool values read come back as float.
495+
# Test np.bool8 and np.bool_ values read come back as float.
496496
df = DataFrame([1, 0, True, False], dtype=np_type)
497497
df.to_excel(path, "test1")
498498

0 commit comments

Comments
 (0)
Please sign in to comment.