Skip to content

Commit 7ee3154

Browse files
REF (string dtype): rename using_pyarrow_string_dtype to using_string_dtype (#59320)
1 parent 9323552 commit 7ee3154

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+122
-176
lines changed

pandas/_config/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,6 @@ def using_nullable_dtypes() -> bool:
5252
return _mode_options["nullable_dtypes"]
5353

5454

55-
def using_pyarrow_string_dtype() -> bool:
55+
def using_string_dtype() -> bool:
5656
_mode_options = _global_config["future"]
5757
return _mode_options["infer_string"]

pandas/_libs/lib.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ from cython cimport (
3737
floating,
3838
)
3939

40-
from pandas._config import using_pyarrow_string_dtype
40+
from pandas._config import using_string_dtype
4141

4242
from pandas._libs.missing import check_na_tuples_nonequal
4343

@@ -2725,7 +2725,7 @@ def maybe_convert_objects(ndarray[object] objects,
27252725
seen.object_ = True
27262726

27272727
elif seen.str_:
2728-
if using_pyarrow_string_dtype() and is_string_array(objects, skipna=True):
2728+
if using_string_dtype() and is_string_array(objects, skipna=True):
27292729
from pandas.core.arrays.string_ import StringDtype
27302730

27312731
dtype = StringDtype(storage="pyarrow_numpy")

pandas/core/construction.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import numpy as np
2020
from numpy import ma
2121

22-
from pandas._config import using_pyarrow_string_dtype
22+
from pandas._config import using_string_dtype
2323

2424
from pandas._libs import lib
2525
from pandas._libs.tslibs import (
@@ -566,11 +566,7 @@ def sanitize_array(
566566
if not is_list_like(data):
567567
if index is None:
568568
raise ValueError("index must be specified when data is not list-like")
569-
if (
570-
isinstance(data, str)
571-
and using_pyarrow_string_dtype()
572-
and original_dtype is None
573-
):
569+
if isinstance(data, str) and using_string_dtype() and original_dtype is None:
574570
from pandas.core.arrays.string_ import StringDtype
575571

576572
dtype = StringDtype("pyarrow_numpy")
@@ -604,14 +600,10 @@ def sanitize_array(
604600
subarr = data
605601
if data.dtype == object:
606602
subarr = maybe_infer_to_datetimelike(data)
607-
if (
608-
object_index
609-
and using_pyarrow_string_dtype()
610-
and is_string_dtype(subarr)
611-
):
603+
if object_index and using_string_dtype() and is_string_dtype(subarr):
612604
# Avoid inference when string option is set
613605
subarr = data
614-
elif data.dtype.kind == "U" and using_pyarrow_string_dtype():
606+
elif data.dtype.kind == "U" and using_string_dtype():
615607
from pandas.core.arrays.string_ import StringDtype
616608

617609
dtype = StringDtype(storage="pyarrow_numpy")

pandas/core/dtypes/cast.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
import numpy as np
2020

21-
from pandas._config import using_pyarrow_string_dtype
21+
from pandas._config import using_string_dtype
2222

2323
from pandas._libs import (
2424
Interval,
@@ -798,7 +798,7 @@ def infer_dtype_from_scalar(val) -> tuple[DtypeObj, Any]:
798798
# coming out as np.str_!
799799

800800
dtype = _dtype_obj
801-
if using_pyarrow_string_dtype():
801+
if using_string_dtype():
802802
from pandas.core.arrays.string_ import StringDtype
803803

804804
dtype = StringDtype(storage="pyarrow_numpy")

pandas/core/indexes/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from pandas._config import (
2424
get_option,
2525
using_copy_on_write,
26-
using_pyarrow_string_dtype,
26+
using_string_dtype,
2727
)
2828

2929
from pandas._libs import (
@@ -7011,7 +7011,7 @@ def insert(self, loc: int, item) -> Index:
70117011

70127012
out = Index._with_infer(new_values, name=self.name)
70137013
if (
7014-
using_pyarrow_string_dtype()
7014+
using_string_dtype()
70157015
and is_string_dtype(out.dtype)
70167016
and new_values.dtype == object
70177017
):

pandas/core/internals/construction.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import numpy as np
1414
from numpy import ma
1515

16-
from pandas._config import using_pyarrow_string_dtype
16+
from pandas._config import using_string_dtype
1717

1818
from pandas._libs import lib
1919

@@ -375,7 +375,7 @@ def ndarray_to_mgr(
375375
bp = BlockPlacement(slice(len(columns)))
376376
nb = new_block_2d(values, placement=bp, refs=refs)
377377
block_values = [nb]
378-
elif dtype is None and values.dtype.kind == "U" and using_pyarrow_string_dtype():
378+
elif dtype is None and values.dtype.kind == "U" and using_string_dtype():
379379
dtype = StringDtype(storage="pyarrow_numpy")
380380

381381
obj_columns = list(values)

pandas/io/feather_format.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
Any,
77
)
88

9-
from pandas._config import using_pyarrow_string_dtype
9+
from pandas._config import using_string_dtype
1010

1111
from pandas._libs import lib
1212
from pandas.compat._optional import import_optional_dependency
@@ -120,7 +120,7 @@ def read_feather(
120120
with get_handle(
121121
path, "rb", storage_options=storage_options, is_text=False
122122
) as handles:
123-
if dtype_backend is lib.no_default and not using_pyarrow_string_dtype():
123+
if dtype_backend is lib.no_default and not using_string_dtype():
124124
return feather.read_feather(
125125
handles.handle, columns=columns, use_threads=bool(use_threads)
126126
)
@@ -137,7 +137,7 @@ def read_feather(
137137
elif dtype_backend == "pyarrow":
138138
return pa_table.to_pandas(types_mapper=pd.ArrowDtype)
139139

140-
elif using_pyarrow_string_dtype():
140+
elif using_string_dtype():
141141
return pa_table.to_pandas(types_mapper=arrow_string_types_mapper())
142142
else:
143143
raise NotImplementedError

pandas/io/orc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
Literal,
1010
)
1111

12-
from pandas._config import using_pyarrow_string_dtype
12+
from pandas._config import using_string_dtype
1313

1414
from pandas._libs import lib
1515
from pandas.compat._optional import import_optional_dependency
@@ -127,7 +127,7 @@ def read_orc(
127127
df = pa_table.to_pandas(types_mapper=mapping.get)
128128
return df
129129
else:
130-
if using_pyarrow_string_dtype():
130+
if using_string_dtype():
131131
types_mapper = arrow_string_types_mapper()
132132
else:
133133
types_mapper = None

pandas/io/parquet.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import warnings
1313
from warnings import catch_warnings
1414

15-
from pandas._config import using_pyarrow_string_dtype
15+
from pandas._config import using_string_dtype
1616
from pandas._config.config import _get_option
1717

1818
from pandas._libs import lib
@@ -257,7 +257,7 @@ def read(
257257
to_pandas_kwargs["types_mapper"] = mapping.get
258258
elif dtype_backend == "pyarrow":
259259
to_pandas_kwargs["types_mapper"] = pd.ArrowDtype # type: ignore[assignment]
260-
elif using_pyarrow_string_dtype():
260+
elif using_string_dtype():
261261
to_pandas_kwargs["types_mapper"] = arrow_string_types_mapper()
262262

263263
manager = _get_option("mode.data_manager", silent=True)

pandas/io/parsers/arrow_parser_wrapper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from typing import TYPE_CHECKING
44
import warnings
55

6-
from pandas._config import using_pyarrow_string_dtype
6+
from pandas._config import using_string_dtype
77

88
from pandas._libs import lib
99
from pandas.compat._optional import import_optional_dependency
@@ -295,7 +295,7 @@ def read(self) -> DataFrame:
295295
dtype_mapping = _arrow_dtype_mapping()
296296
dtype_mapping[pa.null()] = pd.Int64Dtype()
297297
frame = table.to_pandas(types_mapper=dtype_mapping.get)
298-
elif using_pyarrow_string_dtype():
298+
elif using_string_dtype():
299299
frame = table.to_pandas(types_mapper=arrow_string_types_mapper())
300300

301301
else:

0 commit comments

Comments
 (0)