Skip to content

Commit 21da378

Browse files
committed
rstring
1 parent 91c9331 commit 21da378

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

python/pyspark/pandas/strings.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2184,7 +2184,12 @@ def pudf(s: pd.Series) -> pd.Series:
21842184
if expand:
21852185
psdf = psser.to_frame()
21862186
scol = psdf._internal.data_spark_columns[0]
2187-
spark_columns = [scol[i].alias(str(i)) for i in range(n + 1)]
2187+
if ps.get_option("compute.ansi_mode_support"):
2188+
spark_columns = [
2189+
F.try_element_at(scol, F.lit(i + 1)).alias(str(i)) for i in range(n + 1)
2190+
]
2191+
else:
2192+
spark_columns = [scol[i].alias(str(i)) for i in range(n + 1)]
21882193
column_labels = [(i,) for i in range(n + 1)]
21892194
internal = psdf._internal.with_new_columns(
21902195
spark_columns,

python/pyspark/pandas/tests/series/test_string_ops_adv.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
from pyspark import pandas as ps
2323
from pyspark.testing.pandasutils import PandasOnSparkTestCase
2424
from pyspark.testing.sqlutils import SQLTestUtils
25-
from pyspark.testing.utils import is_ansi_mode_test, ansi_mode_not_supported_message
2625

2726

2827
class SeriesStringOpsAdvMixin:
@@ -174,7 +173,6 @@ def test_string_slice_replace(self):
174173
self.check_func(lambda x: x.str.slice_replace(stop=2, repl="X"))
175174
self.check_func(lambda x: x.str.slice_replace(start=1, stop=3, repl="X"))
176175

177-
@unittest.skipIf(is_ansi_mode_test, ansi_mode_not_supported_message)
178176
def test_string_split(self):
179177
self.check_func_on_series(lambda x: repr(x.str.split()), self.pser[:-1])
180178
self.check_func_on_series(lambda x: repr(x.str.split(r"p*")), self.pser[:-1])
@@ -187,7 +185,6 @@ def test_string_split(self):
187185

188186
self.check_func_on_series(lambda x: repr(x.str.split("-", n=1, expand=True)), pser)
189187

190-
@unittest.skipIf(is_ansi_mode_test, ansi_mode_not_supported_message)
191188
def test_string_rsplit(self):
192189
self.check_func_on_series(lambda x: repr(x.str.rsplit()), self.pser[:-1])
193190
self.check_func_on_series(lambda x: repr(x.str.rsplit(r"p*")), self.pser[:-1])
@@ -198,6 +195,8 @@ def test_string_rsplit(self):
198195
with self.assertRaises(NotImplementedError):
199196
self.check_func(lambda x: x.str.rsplit(expand=True))
200197

198+
self.check_func_on_series(lambda x: repr(x.str.rsplit("-", n=1, expand=True)), pser)
199+
201200
def test_string_translate(self):
202201
m = str.maketrans({"a": "X", "e": "Y", "i": None})
203202
self.check_func(lambda x: x.str.translate(m))

0 commit comments

Comments
 (0)