@@ -18,17 +18,17 @@ enable it with:
18
18
19
19
pd.options.future.infer_string = True
20
20
21
- This allows to test your code before the final 3.0 release.
21
+ This allows you to test your code before the final 3.0 release.
22
22
23
23
Background
24
24
----------
25
25
26
26
Historically, pandas has always used the NumPy ``object `` dtype as the default
27
27
to store text data. This has two primary drawbacks. First, ``object `` dtype is
28
- not specific to strings: any Python object can be stored in an ``object` `` -dtype
28
+ not specific to strings: any Python object can be stored in an ``object ``-dtype
29
29
array, not just strings, and seeing ``object `` as the dtype for a column with
30
30
strings is confusing for users. Second, this is not always very efficient (both
31
- performance wise as for memory usage).
31
+ performance wise and for memory usage).
32
32
33
33
Since pandas 1.0, an opt-in string data type has been available, but this has
34
34
not yet been made the default, and uses the ``pd.NA `` scalar to represent
@@ -57,7 +57,7 @@ for more background and details.
57
57
.. - None gets coerced to NaN
58
58
.. - setitem raises an error for non-string data
59
59
60
- Brief intro to the new default string dtype
60
+ Brief introduction to the new default string dtype
61
61
-------------------------------------------
62
62
63
63
By default, pandas will infer this new string dtype instead of object dtype for
@@ -86,14 +86,14 @@ It can also be specified explicitly using the ``"str"`` alias:
86
86
2 NaN
87
87
dtype: str
88
88
89
- In contrast the the current object dtype, the new string dtype will only store
89
+ In contrast to the current object dtype, the new string dtype will only store
90
90
strings. This also means that it will raise an error if you try to store a
91
91
non-string value in it (see below for more details).
92
92
93
93
Missing values with the new string dtype are always represented as ``NaN ``, and
94
- the missing value behaviour is similar as for other default dtypes.
94
+ the missing value behaviour is similar to other default dtypes.
95
95
96
- For the rest, this new string dtype should work the same as how you have been
96
+ This new string dtype should work the same as how you have been
97
97
using pandas with string data today. For example, all string-specific methods
98
98
through the ``str `` accessor will work the same:
99
99
@@ -143,7 +143,7 @@ To check for columns with string data, you should instead use:
143
143
144
144
>> > ser.dtype == " str"
145
145
146
- **How to write compatible code? **
146
+ **How to write compatible code **
147
147
148
148
For code that should work on both pandas 2.x and 3.x, you can use the
149
149
:func: `pandas.api.types.is_string_dtype ` function:
@@ -153,7 +153,7 @@ For code that should work on both pandas 2.x and 3.x, you can use the
153
153
>> > pd.api.types.is_string_dtype(ser.dtype)
154
154
True
155
155
156
- This will return ``True `` for both the object dtype as for the string dtypes.
156
+ This will return ``True `` for both the object dtype and the string dtypes.
157
157
158
158
Hardcoded use of object dtype
159
159
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -253,7 +253,7 @@ impacted by this change.
253
253
** How to write compatible code? **
254
254
255
255
You can update your code to ensure you only set string values in such columns,
256
- or otherwise you have explicitly ensure the column has object dtype first. This
256
+ or otherwise you can explicitly ensure the column has object dtype first. This
257
257
can be done by specifying the dtype explicitly in the constructor, or by using
258
258
the :meth: `~pandas.Series.astype ` method:
259
259
@@ -264,7 +264,7 @@ the :meth:`~pandas.Series.astype` method:
264
264
>> > ser[1 ] = 2.5
265
265
266
266
This ``astype("object") `` call will be redundant when using pandas 2.x, but
267
- this way such code can work for all versions.
267
+ this code will work for all versions.
268
268
269
269
For existing users of the nullable ``StringDtype ``
270
270
--------------------------------------------------
0 commit comments