You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The ``use_nullable_dtypes`` keyword argument has been expanded to the following functions to enable automatic conversion to nullable dtypes (:issue:`36712`)
111
+
The following functions gained a new keyword ``dtype_backend`` (:issue:`36712`)
112
112
113
113
* :func:`read_csv`
114
114
* :func:`read_clipboard`
@@ -124,19 +124,13 @@ The ``use_nullable_dtypes`` keyword argument has been expanded to the following
124
124
* :func:`read_feather`
125
125
* :func:`read_spss`
126
126
* :func:`to_numeric`
127
+
* :meth:`DataFrame.convert_dtypes`
128
+
* :meth:`Series.convert_dtypes`
127
129
128
-
To simplify opting-in to nullable dtypes for these functions, a new option ``nullable_dtypes`` was added that allows setting
129
-
the keyword argument globally to ``True`` if not specified directly. The option can be enabled
130
-
through:
131
-
132
-
.. ipython:: python
133
-
134
-
pd.options.mode.nullable_dtypes =True
135
-
136
-
The option will only work for functions with the keyword ``use_nullable_dtypes``.
130
+
When this option is set to ``"numpy_nullable"`` it will return a :class:`DataFrame` that is
131
+
backed by nullable dtypes.
137
132
138
-
Additionally a new global configuration, ``mode.dtype_backend`` can now be used in conjunction with the parameter ``use_nullable_dtypes=True`` in the following functions
139
-
to select the nullable dtypes implementation.
133
+
When this keyword is set to ``"pyarrow"``, then these functions will return pyarrow-backed nullable :class:`ArrowDtype` DataFrames (:issue:`48957`, :issue:`49997`):
140
134
141
135
* :func:`read_csv`
142
136
* :func:`read_clipboard`
@@ -153,30 +147,21 @@ to select the nullable dtypes implementation.
153
147
* :func:`read_feather`
154
148
* :func:`read_spss`
155
149
* :func:`to_numeric`
156
-
157
-
158
-
And the following methods will also utilize the ``mode.dtype_backend`` option.
159
-
160
150
* :meth:`DataFrame.convert_dtypes`
161
151
* :meth:`Series.convert_dtypes`
162
152
163
-
By default, ``mode.dtype_backend`` is set to ``"pandas"`` to return existing, numpy-backed nullable dtypes, but it can also
164
-
be set to ``"pyarrow"`` to return pyarrow-backed, nullable :class:`ArrowDtype` (:issue:`48957`, :issue:`49997`).
165
-
166
153
.. ipython:: python
167
154
168
155
import io
169
156
data = io.StringIO("""a,b,c,d,e,f,g,h,i
170
157
1,2.5,True,a,,,,,
171
158
3,4.5,False,b,6,7.5,True,a,
172
159
""")
173
-
with pd.option_context("mode.dtype_backend", "pandas"):
174
-
df = pd.read_csv(data, use_nullable_dtypes=True)
160
+
df = pd.read_csv(data, dtype_backend="pyarrow")
175
161
df.dtypes
176
162
177
163
data.seek(0)
178
-
with pd.option_context("mode.dtype_backend", "pyarrow"):
0 commit comments