Skip to content

Commit 61af94a

Browse files
simonjayhawkinsluckyvs1
authored andcommitted
DOC: np.bool -> np.bool_ (pandas-dev#39019)
1 parent 63395db commit 61af94a

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
@@ -152,6 +152,11 @@ repos:
152152
\#\ type:\s?ignore(?!\[)
153153
language: pygrep
154154
types: [python]
155+
- id: np-bool
156+
name: Check for use of np.bool instead of np.bool_
157+
entry: np\.bool[^_8]
158+
language: pygrep
159+
types_or: [python, cython, rst]
155160
- id: no-os-remove
156161
name: Check code for instances of os.remove
157162
entry: os\.remove

asv_bench/benchmarks/groupby.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ class TransformBools:
627627
def setup(self):
628628
N = 120000
629629
transition_points = np.sort(np.random.choice(np.arange(N), 1400))
630-
transitions = np.zeros(N, dtype=np.bool)
630+
transitions = np.zeros(N, dtype=np.bool_)
631631
transitions[transition_points] = True
632632
self.g = transitions.cumsum()
633633
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)