Skip to content
Closed
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,10 @@ def test_pandas_series_numpy_backed(self):
import numpy as np
import pandas as pd
import pyarrow as pa
from pyspark.loose_version import LooseVersion

# pandas >= 3 infers large_string instead of string for object-dtype string Series
string_type = pa.large_string() if LooseVersion(pd.__version__) >= "3.0.0" else pa.string()

sg = ZoneInfo("Asia/Singapore")
la = "America/Los_Angeles"
Expand All @@ -315,7 +319,7 @@ def test_pandas_series_numpy_backed(self):
(pd.Series([np.inf, 1.0, 2.0]), pa.float64()),
(pd.Series([-np.inf, 1.0, 2.0]), pa.float64()),
# String
(pd.Series(["a", "b", "c"]), pa.string()),
(pd.Series(["a", "b", "c"]), string_type),
# Boolean
(pd.Series([True, False, True]), pa.bool_()),
# Temporal
Expand Down Expand Up @@ -356,6 +360,10 @@ def test_pandas_series_nullable_extension(self):
import numpy as np
import pandas as pd
import pyarrow as pa
from pyspark.loose_version import LooseVersion

# pandas >= 3 uses pyarrow-backed StringDtype, which infers large_string
string_type = pa.large_string() if LooseVersion(pd.__version__) >= "3.0.0" else pa.string()

cases = [
# Integer
Expand All @@ -379,8 +387,8 @@ def test_pandas_series_nullable_extension(self):
(pd.Series([True, False, True], dtype=pd.BooleanDtype()), pa.bool_()),
(pd.Series([True, False, None], dtype=pd.BooleanDtype()), pa.bool_()),
# String
(pd.Series(["a", "b", "c"], dtype=pd.StringDtype()), pa.string()),
(pd.Series(["a", "b", None], dtype=pd.StringDtype()), pa.string()),
(pd.Series(["a", "b", "c"], dtype=pd.StringDtype()), string_type),
(pd.Series(["a", "b", None], dtype=pd.StringDtype()), string_type),
]
self._run_inference_tests(cases)

Expand Down