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
ENH: Allow convert_dtypes to convert to pd.ArrowDtype (#50094)
* Refactor to mode.nullable_backend
* Update code paths
* Add tests and whatsnew
* Add unit test converting pandas nullable to pyarrow
* Typing
* Ensure comparison with string
* typing and another comparison
The ``use_nullable_dtypes`` keyword argument has been expanded to the following functions to enable automatic conversion to nullable dtypes (:issue:`36712`)
37
37
38
38
* :func:`read_csv`
39
39
* :func:`read_excel`
40
40
* :func:`read_sql`
41
41
42
-
Additionally a new global configuration, ``io.nullable_backend`` can now be used in conjunction with the parameter ``use_nullable_dtypes=True`` in the following functions
42
+
Additionally a new global configuration, ``mode.nullable_backend`` can now be used in conjunction with the parameter ``use_nullable_dtypes=True`` in the following functions
43
43
to select the nullable dtypes implementation.
44
44
45
45
* :func:`read_csv` (with ``engine="pyarrow"``)
46
46
* :func:`read_excel`
47
47
* :func:`read_parquet`
48
48
* :func:`read_orc`
49
49
50
-
By default, ``io.nullable_backend`` is set to ``"pandas"`` to return existing, numpy-backed nullable dtypes, but it can also
51
-
be set to ``"pyarrow"`` to return pyarrow-backed, nullable :class:`ArrowDtype` (:issue:`48957`).
50
+
51
+
And the following methods will also utilize the ``mode.nullable_backend`` option.
52
+
53
+
* :meth:`DataFrame.convert_dtypes`
54
+
* :meth:`Series.convert_dtypes`
55
+
56
+
By default, ``mode.nullable_backend`` is set to ``"pandas"`` to return existing, numpy-backed nullable dtypes, but it can also
57
+
be set to ``"pyarrow"`` to return pyarrow-backed, nullable :class:`ArrowDtype` (:issue:`48957`, :issue:`49997`).
52
58
53
59
.. ipython:: python
54
60
@@ -57,12 +63,12 @@ be set to ``"pyarrow"`` to return pyarrow-backed, nullable :class:`ArrowDtype` (
57
63
1,2.5,True,a,,,,,
58
64
3,4.5,False,b,6,7.5,True,a,
59
65
""")
60
-
with pd.option_context("io.nullable_backend", "pandas"):
66
+
with pd.option_context("mode.nullable_backend", "pandas"):
61
67
df = pd.read_csv(data, use_nullable_dtypes=True)
62
68
df.dtypes
63
69
64
70
data.seek(0)
65
-
with pd.option_context("io.nullable_backend", "pyarrow"):
71
+
with pd.option_context("mode.nullable_backend", "pyarrow"):
0 commit comments