Skip to content

Commit 998824a

Browse files
DOC: add storage and na_value to StringDtype reference page
1 parent a505423 commit 998824a

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

doc/source/reference/arrays.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,8 @@ with a bool :class:`numpy.ndarray`.
637637
DatetimeTZDtype.tz
638638
PeriodDtype.freq
639639
IntervalDtype.subtype
640+
StringDtype.storage
641+
StringDtype.na_value
640642

641643
*********
642644
Utilities

pandas/core/arrays/string_.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ class StringDtype(StorageExtensionDtype):
119119
120120
Attributes
121121
----------
122-
None
122+
storage
123+
na_value
123124
124125
Methods
125126
-------
@@ -149,8 +150,24 @@ def name(self) -> str: # type: ignore[override]
149150
# follows NumPy semantics, which uses nan.
150151
@property
151152
def na_value(self) -> libmissing.NAType | float: # type: ignore[override]
153+
"""
154+
The missing value representation for this dtype.
155+
156+
This value indicates which missing value semantics are used by this dtype.
157+
Returns ``np.nan`` for the default string dtype with NumPy semantics,
158+
and ``pd.NA`` for the opt-in string dtype with pandas NA semantics.
159+
"""
152160
return self._na_value
153161

162+
@property
163+
def storage(self) -> str:
164+
"""
165+
The storage backend for this dtype.
166+
167+
Can be either "pyarrow" or "python".
168+
"""
169+
return self._storage
170+
154171
_metadata = ("storage", "_na_value") # type: ignore[assignment]
155172

156173
def __init__(
@@ -185,7 +202,7 @@ def __init__(
185202
elif na_value is not libmissing.NA:
186203
raise ValueError(f"'na_value' must be np.nan or pd.NA, got {na_value}")
187204

188-
self.storage = cast(str, storage)
205+
self._storage = cast(str, storage)
189206
self._na_value = na_value
190207

191208
def __repr__(self) -> str:

0 commit comments

Comments
 (0)