Skip to content

Commit fcfefdb

Browse files
committed
Update
1 parent 093fede commit fcfefdb

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

pandas/core/construction.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,11 @@ def sanitize_array(
611611
dtype = StringDtype(na_value=np.nan)
612612
subarr = dtype.construct_array_type()._from_sequence(data, dtype=dtype)
613613

614-
if subarr is data and copy:
614+
if (
615+
subarr is data
616+
or subarr.dtype == "str"
617+
and subarr.dtype.storage == "python"
618+
) and copy:
615619
subarr = subarr.copy()
616620

617621
else:

pandas/tests/indexes/test_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def test_constructor_copy(self, using_infer_string):
8282
new_index = Index(arr, copy=True, name="name")
8383
assert isinstance(new_index, Index)
8484
assert new_index.name == "name"
85-
if using_infer_string and HAS_PYARROW:
85+
if using_infer_string:
8686
tm.assert_extension_array_equal(
8787
new_index.values, pd.array(arr, dtype="str")
8888
)

0 commit comments

Comments
 (0)