Skip to content

REF: Rename mode.nullable_backend to mode.dtype_backend #50291

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Dec 22, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -6435,9 +6435,9 @@ def convert_dtypes(

.. versionadded:: 2.0
The nullable dtype implementation can be configured by calling
``pd.set_option("mode.nullable_backend", "pandas")`` to use
``pd.set_option("mode.dtype_backend", "pandas")`` to use
numpy-backed nullable dtypes or
``pd.set_option("mode.nullable_backend", "pyarrow")`` to use
``pd.set_option("mode.dtype_backend", "pyarrow")`` to use
pyarrow-backed nullable dtypes (using ``pd.ArrowDtype``).

Examples
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -5410,7 +5410,7 @@ def _convert_dtypes(
input_series = input_series.copy()

if convert_string or convert_integer or convert_boolean or convert_floating:
nullable_backend = get_option("mode.nullable_backend")
nullable_backend = get_option("mode.dtype_backend")
inferred_dtype = convert_dtypes(
input_series._values,
convert_string,
Expand Down
10 changes: 5 additions & 5 deletions pandas/io/orc.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,16 @@ def read_orc(
for the resulting DataFrame.

The nullable dtype implementation can be configured by calling
``pd.set_option("mode.nullable_backend", "pandas")`` to use
``pd.set_option("mode.dtype_backend", "pandas")`` to use
numpy-backed nullable dtypes or
``pd.set_option("mode.nullable_backend", "pyarrow")`` to use
``pd.set_option("mode.dtype_backend", "pyarrow")`` to use
pyarrow-backed nullable dtypes (using ``pd.ArrowDtype``).

.. versionadded:: 2.0.0

.. note

Currently only ``mode.nullable_backend`` set to ``"pyarrow"`` is supported.
Currently only ``mode.dtype_backend`` set to ``"pyarrow"`` is supported.

**kwargs
Any additional kwargs are passed to pyarrow.
Expand All @@ -90,10 +90,10 @@ def read_orc(
orc_file = orc.ORCFile(handles.handle)
pa_table = orc_file.read(columns=columns, **kwargs)
if use_nullable_dtypes:
nullable_backend = get_option("mode.nullable_backend")
nullable_backend = get_option("mode.dtype_backend")
if nullable_backend != "pyarrow":
raise NotImplementedError(
f"mode.nullable_backend set to {nullable_backend} is not implemented."
f"mode.dtype_backend set to {nullable_backend} is not implemented."
)
df = DataFrame(
{
Expand Down
6 changes: 3 additions & 3 deletions pandas/io/parquet.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def read(
) -> DataFrame:
kwargs["use_pandas_metadata"] = True

nullable_backend = get_option("mode.nullable_backend")
nullable_backend = get_option("mode.dtype_backend")
to_pandas_kwargs = {}
if use_nullable_dtypes:
import pandas as pd
Expand Down Expand Up @@ -509,9 +509,9 @@ def read_parquet(
.. versionadded:: 1.2.0

The nullable dtype implementation can be configured by calling
``pd.set_option("mode.nullable_backend", "pandas")`` to use
``pd.set_option("mode.dtype_backend", "pandas")`` to use
numpy-backed nullable dtypes or
``pd.set_option("mode.nullable_backend", "pyarrow")`` to use
``pd.set_option("mode.dtype_backend", "pyarrow")`` to use
pyarrow-backed nullable dtypes (using ``pd.ArrowDtype``).

.. versionadded:: 2.0.0
Expand Down
2 changes: 1 addition & 1 deletion pandas/io/parsers/arrow_parser_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def read(self) -> DataFrame:
)
if (
self.kwds["use_nullable_dtypes"]
and get_option("mode.nullable_backend") == "pyarrow"
and get_option("mode.dtype_backend") == "pyarrow"
):
frame = DataFrame(
{
Expand Down
2 changes: 1 addition & 1 deletion pandas/io/parsers/base_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ def _infer_types(
use_nullable_dtypes: Literal[True] | Literal[False] = (
self.use_nullable_dtypes and no_dtype_specified
)
nullable_backend = get_option("mode.nullable_backend")
nullable_backend = get_option("mode.dtype_backend")
result: ArrayLike

if try_num_bool and is_object_dtype(values.dtype):
Expand Down
8 changes: 4 additions & 4 deletions pandas/io/parsers/readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,9 +399,9 @@
implementation, even if no nulls are present.

The nullable dtype implementation can be configured by calling
``pd.set_option("mode.nullable_backend", "pandas")`` to use
``pd.set_option("mode.dtype_backend", "pandas")`` to use
numpy-backed nullable dtypes or
``pd.set_option("mode.nullable_backend", "pyarrow")`` to use
``pd.set_option("mode.dtype_backend", "pyarrow")`` to use
pyarrow-backed nullable dtypes (using ``pd.ArrowDtype``).

.. versionadded:: 2.0
Expand Down Expand Up @@ -561,11 +561,11 @@ def _read(
)
elif (
kwds.get("use_nullable_dtypes", False)
and get_option("mode.nullable_backend") == "pyarrow"
and get_option("mode.dtype_backend") == "pyarrow"
):
raise NotImplementedError(
f"use_nullable_dtypes=True and engine={kwds['engine']} with "
"mode.nullable_backend set to 'pyarrow' is not implemented."
"mode.dtype_backend set to 'pyarrow' is not implemented."
)
else:
chunksize = validate_integer("chunksize", chunksize, 1)
Expand Down
6 changes: 3 additions & 3 deletions pandas/tests/frame/methods/test_convert_dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def test_pyarrow_nullable_backend(self):
"f": pd.Series(pd.timedelta_range("1D", periods=3)),
}
)
with pd.option_context("mode.nullable_backend", "pyarrow"):
with pd.option_context("mode.dtype_backend", "pyarrow"):
result = df.convert_dtypes()
expected = pd.DataFrame(
{
Expand Down Expand Up @@ -93,7 +93,7 @@ def test_pyarrow_nullable_backend(self):
def test_pyarrow_nullable_backend_already_pyarrow(self):
pytest.importorskip("pyarrow")
expected = pd.DataFrame([1, 2, 3], dtype="int64[pyarrow]")
with pd.option_context("mode.nullable_backend", "pyarrow"):
with pd.option_context("mode.dtype_backend", "pyarrow"):
result = expected.convert_dtypes()
tm.assert_frame_equal(result, expected)

Expand All @@ -107,7 +107,7 @@ def test_pyarrow_nullable_backend_from_pandas_nullable(self):
"d": pd.Series([None, 100.5, 200], dtype="Float64"),
}
)
with pd.option_context("mode.nullable_backend", "pyarrow"):
with pd.option_context("mode.dtype_backend", "pyarrow"):
result = df.convert_dtypes()
expected = pd.DataFrame(
{
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/io/excel/test_readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ def test_use_nullable_dtypes(self, read_ext, nullable_backend):
)
with tm.ensure_clean(read_ext) as file_path:
df.to_excel(file_path, "test", index=False)
with pd.option_context("mode.nullable_backend", nullable_backend):
with pd.option_context("mode.dtype_backend", nullable_backend):
result = pd.read_excel(
file_path, sheet_name="test", use_nullable_dtypes=True
)
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/io/parser/dtypes/test_dtypes_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ def test_use_nullable_dtypes_pyarrow_backend(all_parsers, request):
1,2.5,True,a,,,,,12-31-2019,
3,4.5,False,b,6,7.5,True,a,12-31-2019,
"""
with pd.option_context("mode.nullable_backend", "pyarrow"):
with pd.option_context("mode.dtype_backend", "pyarrow"):
if parser.engine != "pyarrow":
request.node.add_marker(
pytest.mark.xfail(
Expand Down
6 changes: 3 additions & 3 deletions pandas/tests/io/test_orc.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,9 @@ def test_orc_use_nullable_dtypes_pandas_backend_not_supported(dirpath):
input_file = os.path.join(dirpath, "TestOrcFile.emptyFile.orc")
with pytest.raises(
NotImplementedError,
match="mode.nullable_backend set to pandas is not implemented.",
match="mode.dtype_backend set to pandas is not implemented.",
):
with pd.option_context("mode.nullable_backend", "pandas"):
with pd.option_context("mode.dtype_backend", "pandas"):
read_orc(input_file, use_nullable_dtypes=True)


Expand All @@ -337,7 +337,7 @@ def test_orc_use_nullable_dtypes_pyarrow_backend():
}
)
bytes_data = df.copy().to_orc()
with pd.option_context("mode.nullable_backend", "pyarrow"):
with pd.option_context("mode.dtype_backend", "pyarrow"):
result = read_orc(BytesIO(bytes_data), use_nullable_dtypes=True)
expected = pd.DataFrame(
{
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/io/test_parquet.py
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,7 @@ def test_read_use_nullable_types_pyarrow_config(self, pa, df_full):
pd.ArrowDtype(pyarrow.timestamp(unit="us", tz="Europe/Brussels"))
)

with pd.option_context("mode.nullable_backend", "pyarrow"):
with pd.option_context("mode.dtype_backend", "pyarrow"):
check_round_trip(
df,
engine=pa,
Expand Down