@@ -84,6 +84,8 @@ class StringDtype(ExtensionDtype):
84
84
string[python]
85
85
"""
86
86
87
+ name = "string"
88
+
87
89
#: StringDtype.na_value uses pandas.NA
88
90
na_value = libmissing .NA
89
91
_metadata = ("storage" ,)
@@ -102,10 +104,6 @@ def __init__(self, storage=None):
102
104
103
105
self .storage = storage
104
106
105
- @property
106
- def name (self ):
107
- return f"string[{ self .storage } ]"
108
-
109
107
@property
110
108
def type (self ) -> type [str ]:
111
109
return str
@@ -182,6 +180,9 @@ def construct_array_type( # type: ignore[override]
182
180
return ArrowStringArray
183
181
184
182
def __repr__ (self ):
183
+ return f"string[{ self .storage } ]"
184
+
185
+ def __str__ (self ):
185
186
return self .name
186
187
187
188
def __from_arrow__ (
@@ -268,7 +269,7 @@ class StringArray(PandasArray):
268
269
>>> pd.array(['This is', 'some text', None, 'data.'], dtype="string")
269
270
<StringArray>
270
271
['This is', 'some text', <NA>, 'data.']
271
- Length: 4, dtype: string[python]
272
+ Length: 4, dtype: string
272
273
273
274
Unlike arrays instantiated with ``dtype="object"``, ``StringArray``
274
275
will convert the values to strings.
@@ -280,7 +281,7 @@ class StringArray(PandasArray):
280
281
>>> pd.array(['1', 1], dtype="string")
281
282
<StringArray>
282
283
['1', '1']
283
- Length: 2, dtype: string[python]
284
+ Length: 2, dtype: string
284
285
285
286
However, instantiating StringArrays directly with non-strings will raise an error.
286
287
0 commit comments