Skip to content

Commit 30fa5f3

Browse files
authored
SNOW-2390752 - Series replace fails with KeyError ( Test Only ) (#3929)
1 parent b505e92 commit 30fa5f3

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

tests/integ/modin/frame/test_replace.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,46 @@ def snow_df():
2323
)
2424

2525

26+
@sql_count_checker(query_count=3)
27+
def test_replace_SNOW_2390752_dataframe():
28+
native_df = native_pd.DataFrame(
29+
{
30+
"col1": ["one", "two", "two", "three", "two", "four"],
31+
"col2": [
32+
"abc",
33+
"pqr",
34+
"xyz",
35+
None,
36+
"pqr",
37+
"xyz",
38+
],
39+
}
40+
)
41+
snow_df = pd.DataFrame(native_df)
42+
modin_df = snow_df.move_to("Pandas")
43+
assert modin_df.get_backend() == "Pandas"
44+
45+
eval_snowpark_pandas_result(
46+
snow_df, native_df, lambda df: df["col1"].replace(["two"], ["a"])
47+
)
48+
snow_result = snow_df["col1"].replace(["two"], ["a"])
49+
modin_result = modin_df["col1"].replace(["two"], ["a"])
50+
assert modin_result.to_pandas().equals(snow_result.to_pandas())
51+
52+
53+
@sql_count_checker(query_count=3, join_count=2)
54+
def test_replace_SNOW_2390752_series():
55+
input_dict_native = native_pd.Series(
56+
{"a": "apple", "socks": "socks are darned", "b": "bee"}
57+
)
58+
input_dict = pd.Series(input_dict_native)
59+
input_dict_pandas_modin = input_dict.move_to("Pandas")
60+
assert input_dict_pandas_modin.get_backend() == "Pandas"
61+
expected = input_dict_native["socks"].replace("darned", "clean")
62+
assert input_dict["socks"].replace("darned", "clean") == expected
63+
assert input_dict_pandas_modin["socks"].replace("darned", "clean") == expected
64+
65+
2666
@pytest.mark.parametrize(
2767
"to_replace, value",
2868
[

0 commit comments

Comments
 (0)