|
41 | 41 | @register_extension_dtype |
42 | 42 | class BooleanDtype(BaseMaskedDtype): |
43 | 43 | """ |
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. |
45 | 47 |
|
46 | 48 | .. warning:: |
47 | 49 |
|
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. |
50 | 52 |
|
51 | 53 | Attributes |
52 | 54 | ---------- |
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_). |
58 | 65 |
|
59 | 66 | See Also |
60 | 67 | -------- |
| 68 | + BooleanArray : Extension array for boolean data with missing values. |
61 | 69 | 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. |
62 | 73 |
|
63 | 74 | Examples |
64 | 75 | -------- |
| 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 | +
|
65 | 88 | >>> pd.BooleanDtype() |
66 | 89 | BooleanDtype |
67 | | - """ |
| 90 | +
|
| 91 | + Check that a Series has BooleanDtype: |
| 92 | +
|
| 93 | + >>> s.dtype |
| 94 | + BooleanDtype |
| 95 | +""" |
68 | 96 |
|
69 | 97 | name: ClassVar[str] = "boolean" |
70 | 98 |
|
|
0 commit comments