Skip to content

Commit fe4ea7e

Browse files
committed
DOC: Standardize and expand docstring for BooleanDtype (fixes #61939)
1 parent 7f670c1 commit fe4ea7e

File tree

1 file changed

+37
-9
lines changed

1 file changed

+37
-9
lines changed

pandas/core/arrays/boolean.py

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,30 +41,58 @@
4141
@register_extension_dtype
4242
class BooleanDtype(BaseMaskedDtype):
4343
"""
44-
Extension dtype for boolean data.
44+
Extension dtype for boolean data, with support for missing values.
45+
46+
BooleanDtype is used to represent boolean data (True/False) with the ability to handle missing (NA) values through pandas' extension dtype system. This allows for efficient storage, computation, and interoperability with nullable boolean arrays in pandas objects.
4547
4648
.. warning::
4749
48-
BooleanDtype is considered experimental. The implementation and
49-
parts of the API may change without warning.
50+
BooleanDtype is considered experimental. The implementation and
51+
parts of the API may change without warning.
5052
5153
Attributes
5254
----------
53-
None
54-
55-
Methods
56-
-------
57-
None
55+
name : str
56+
String identifying the dtype ('boolean').
57+
na_value : pandas.NA
58+
The scalar missing value used for this dtype.
59+
kind : str
60+
The kind of data ('b' for boolean).
61+
numpy_dtype : numpy.dtype
62+
The underlying NumPy dtype used ('bool').
63+
type : type
64+
The scalar type for elements of this dtype (np.bool_).
5865
5966
See Also
6067
--------
68+
BooleanArray : Extension array for boolean data with missing values.
6169
StringDtype : Extension dtype for string data.
70+
array : Create a pandas array with a specific dtype.
71+
Series : One-dimensional ndarray with axis labels.
72+
DataFrame : Two-dimensional, size-mutable, tabular data.
6273
6374
Examples
6475
--------
76+
Create a Series with BooleanDtype:
77+
78+
>>> import pandas as pd
79+
>>> s = pd.Series([True, False, None], dtype='boolean')
80+
>>> s
81+
0 True
82+
1 False
83+
2 <NA>
84+
dtype: boolean
85+
86+
You can construct BooleanDtype directly:
87+
6588
>>> pd.BooleanDtype()
6689
BooleanDtype
67-
"""
90+
91+
Check that a Series has BooleanDtype:
92+
93+
>>> s.dtype
94+
BooleanDtype
95+
"""
6896

6997
name: ClassVar[str] = "boolean"
7098

0 commit comments

Comments
 (0)