MCPcopy Create free account
hub / github.com/apache/arrow / test_replace_slice

Function test_replace_slice

python/pyarrow/tests/test_compute.py:1209–1230  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1207
1208@pytest.mark.pandas
1209def test_replace_slice():
1210 offsets = range(-3, 4)
1211
1212 arr = pa.array([None, '', 'a', 'ab', 'abc', 'abcd', 'abcde'])
1213 series = arr.to_pandas().astype(object).replace({np.nan: None})
1214 for start in offsets:
1215 for stop in offsets:
1216 expected = series.str.slice_replace(start, stop, 'XX')
1217 actual = pc.binary_replace_slice(
1218 arr, start=start, stop=stop, replacement='XX')
1219 assert actual.tolist() == expected.tolist()
1220 # Positional options
1221 assert pc.binary_replace_slice(arr, start, stop, 'XX') == actual
1222
1223 arr = pa.array([None, '', 'π', 'πb', 'πbθ', 'πbθd', 'πbθde'])
1224 series = arr.to_pandas().astype(object).replace({np.nan: None})
1225 for start in offsets:
1226 for stop in offsets:
1227 expected = series.str.slice_replace(start, stop, 'XX')
1228 actual = pc.utf8_replace_slice(
1229 arr, start=start, stop=stop, replacement='XX')
1230 assert actual.tolist() == expected.tolist()
1231
1232
1233def test_replace_plain():

Callers

nothing calls this directly

Calls 1

arrayMethod · 0.45

Tested by

no test coverage detected