Skip to content

Commit d01326f

Browse files
update tests
1 parent f88f0c5 commit d01326f

File tree

8 files changed

+17
-18
lines changed

8 files changed

+17
-18
lines changed

pandas/tests/arrays/categorical/test_constructors.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -736,9 +736,7 @@ def test_interval(self):
736736

737737
def test_categorical_extension_array_nullable(self, nulls_fixture):
738738
# GH:
739-
arr = pd.arrays.StringArray._from_sequence(
740-
[nulls_fixture] * 2, dtype=pd.StringDtype()
741-
)
739+
arr = pd.array([nulls_fixture] * 2, dtype=pd.StringDtype())
742740
result = Categorical(arr)
743741
assert arr.dtype == result.categories.dtype
744742
expected = Categorical(Series([pd.NA, pd.NA], dtype=arr.dtype))

pandas/tests/copy_view/test_array.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def test_dataframe_array_ea_dtypes():
128128

129129

130130
def test_dataframe_array_string_dtype():
131-
df = DataFrame({"a": ["a", "b"]}, dtype="string")
131+
df = DataFrame({"a": ["a", "b"]}, dtype="string[python]")
132132
arr = np.asarray(df)
133133
assert np.shares_memory(arr, get_array(df, "a"))
134134
assert arr.flags.writeable is False

pandas/tests/copy_view/test_astype.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def test_astype_numpy_to_ea():
8383

8484

8585
@pytest.mark.parametrize(
86-
"dtype, new_dtype", [("object", "string"), ("string", "object")]
86+
"dtype, new_dtype", [("object", "string[python]"), ("string[python]", "object")]
8787
)
8888
def test_astype_string_and_object(dtype, new_dtype):
8989
df = DataFrame({"a": ["a", "b", "c"]}, dtype=dtype)
@@ -96,7 +96,7 @@ def test_astype_string_and_object(dtype, new_dtype):
9696

9797

9898
@pytest.mark.parametrize(
99-
"dtype, new_dtype", [("object", "string"), ("string", "object")]
99+
"dtype, new_dtype", [("object", "string[python]"), ("string[python]", "object")]
100100
)
101101
def test_astype_string_and_object_update_original(dtype, new_dtype):
102102
df = DataFrame({"a": ["a", "b", "c"]}, dtype=dtype)

pandas/tests/dtypes/test_common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def test_period_dtype(self, dtype):
117117
"float": np.dtype(np.float64),
118118
"object": np.dtype(object),
119119
"category": com.pandas_dtype("category"),
120-
"string": pd.StringDtype(),
120+
"string": pd.StringDtype("python"),
121121
}
122122

123123

pandas/tests/frame/methods/test_convert_dtypes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ def test_convert_dtypes_avoid_block_splitting(self):
199199
{
200200
"a": [1, 2, 3],
201201
"b": [4, 5, 6],
202-
"c": pd.Series(["a"] * 3, dtype="string[python]"),
202+
"c": pd.Series(["a"] * 3, dtype="string"),
203203
}
204204
)
205205
tm.assert_frame_equal(result, expected)
@@ -209,7 +209,7 @@ def test_convert_dtypes_from_arrow(self):
209209
# GH#56581
210210
df = pd.DataFrame([["a", datetime.time(18, 12)]], columns=["a", "b"])
211211
result = df.convert_dtypes()
212-
expected = df.astype({"a": "string[python]"})
212+
expected = df.astype({"a": "string"})
213213
tm.assert_frame_equal(result, expected)
214214

215215
def test_convert_dtype_pyarrow_timezone_preserve(self):

pandas/tests/io/excel/test_readers.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,10 @@ def test_dtype_backend(self, read_ext, dtype_backend, engine, tmp_excel):
657657
for col in df.columns
658658
}
659659
)
660+
661+
# pandas uses large_string by default, but pyarrow infers string
662+
expected["d"] = expected["d"].astype(pd.ArrowDtype(pa.string()))
663+
expected["h"] = expected["h"].astype(pd.ArrowDtype(pa.string()))
660664
# pyarrow by default infers timestamp resolution as us, not ns
661665
expected["i"] = ArrowExtensionArray(
662666
expected["i"].array._pa_array.cast(pa.timestamp(unit="us"))

pandas/tests/io/test_orc.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import pandas as pd
1313
from pandas import read_orc
1414
import pandas._testing as tm
15-
from pandas.core.arrays import StringArray
1615

1716
pytest.importorskip("pyarrow.orc")
1817

@@ -368,13 +367,9 @@ def test_orc_dtype_backend_numpy_nullable():
368367

369368
expected = pd.DataFrame(
370369
{
371-
"string": StringArray(np.array(["a", "b", "c"], dtype=np.object_)),
372-
"string_with_nan": StringArray(
373-
np.array(["a", pd.NA, "c"], dtype=np.object_)
374-
),
375-
"string_with_none": StringArray(
376-
np.array(["a", pd.NA, "c"], dtype=np.object_)
377-
),
370+
"string": pd.array(np.array(["a", "b", "c"], dtype=np.object_)),
371+
"string_with_nan": pd.array(np.array(["a", pd.NA, "c"], dtype=np.object_)),
372+
"string_with_none": pd.array(np.array(["a", pd.NA, "c"], dtype=np.object_)),
378373
"int": pd.Series([1, 2, 3], dtype="Int64"),
379374
"int_with_nan": pd.Series([1, pd.NA, 3], dtype="Int64"),
380375
"na_only": pd.Series([pd.NA, pd.NA, pd.NA], dtype="Int64"),

pandas/tests/series/test_constructors.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2137,7 +2137,9 @@ def test_series_string_inference_storage_definition(self):
21372137
# but after PDEP-14 (string dtype), it was decided to keep dtype="string"
21382138
# returning the NA string dtype, so expected is changed from
21392139
# "string[pyarrow_numpy]" to "string[python]"
2140-
expected = Series(["a", "b"], dtype="string[python]")
2140+
expected = Series(
2141+
["a", "b"], dtype="string[pyarrow]" if HAS_PYARROW else "string[python]"
2142+
)
21412143
with pd.option_context("future.infer_string", True):
21422144
result = Series(["a", "b"], dtype="string")
21432145
tm.assert_series_equal(result, expected)

0 commit comments

Comments
 (0)