Skip to content

Commit 44abe87

Browse files
committed
clean up rst and doc strings
1 parent e5c533f commit 44abe87

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

doc/source/whatsnew/v1.1.0.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ For example:
2525
2626
In [1]: pd.Series([1, "abc", np.nan], dtype="string")
2727
Out[1]: ValueError: StringArray requires a sequence of strings or pandas.NA
28-
In [2]: pd.Series([1,2, np.nan], dtype="Int64").astype("string")
28+
In [2]: pd.Series([1, 2, np.nan], dtype="Int64").astype("string")
2929
Out[2]: ValueError: StringArray requires a sequence of strings or pandas.NA
3030
3131
This meant that in order to convert arbitrary data to :class:`StringDtype`, you would often have to use ``.astype(str).astype('string')``, which was not intuitive.
@@ -36,7 +36,7 @@ This meant that in order to convert arbitrary data to :class:`StringDtype`, you
3636
ser = pd.Series([1, "abc", np.nan], dtype="string")
3737
ser
3838
ser[0]
39-
pd.Series([1,2, np.nan], dtype="Int64").astype("string")
39+
pd.Series([1, 2, np.nan], dtype="Int64").astype("string")
4040
4141
4242
.. _whatsnew_110.period_index_partial_string_slicing:

pandas/core/arrays/string_.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ class StringArray(PandasArray):
104104
105105
.. versionadded:: 1.0.0
106106
107+
.. versionchanged:: 1.1.0
108+
109+
``StringArray`` allow non-string input values, but will always convert the
110+
values to strings. (Before Pandas 1.1 non-string values were not allowed).
111+
107112
.. warning::
108113
109114
StringArray is considered experimental. The implementation and
@@ -152,13 +157,13 @@ class StringArray(PandasArray):
152157
['This is', 'some text', <NA>, 'data.']
153158
Length: 4, dtype: string
154159
155-
Unlike ``object`` dtype arrays, ``StringArray`` doesn't allow non-string
156-
values.
160+
Like ``object`` dtype arrays instantiated with ``dtype="str"``, ``StringArray``
161+
allows non-string values but will always convert the values to strings.
157162
158163
>>> pd.array(['1', 1], dtype="string")
159-
Traceback (most recent call last):
160-
...
161-
ValueError: StringArray requires an object-dtype ndarray of strings.
164+
<StringArray>
165+
['1', '1']
166+
Length: 2, dtype: string
162167
163168
For comparison methods, this returns a :class:`pandas.BooleanArray`
164169

0 commit comments

Comments
 (0)