Skip to content

Commit 3c44745

Browse files
NumanIjazNuman
and
Numan
authored
TST: Test for setting indexed Series of type string[pyarrow] using dataframe loc (#52514)
* TST: Test for setting indexed pyarrow string Series using loc * review feedback: pyarrow import --------- Co-authored-by: Numan <[email protected]>
1 parent e58d1ba commit 3c44745

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

pandas/tests/indexing/test_loc.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2970,6 +2970,28 @@ def test_loc_periodindex_3_levels():
29702970
assert mi_series.loc[(p_index[0], "A", "B")] == 1.0
29712971

29722972

2973+
def test_loc_setitem_pyarrow_strings():
2974+
# GH#52319
2975+
pytest.importorskip("pyarrow")
2976+
df = DataFrame(
2977+
{
2978+
"strings": Series(["A", "B", "C"], dtype="string[pyarrow]"),
2979+
"ids": Series([True, True, False]),
2980+
}
2981+
)
2982+
new_value = Series(["X", "Y"])
2983+
df.loc[df.ids, "strings"] = new_value
2984+
2985+
expected_df = DataFrame(
2986+
{
2987+
"strings": Series(["X", "Y", "C"], dtype="string[pyarrow]"),
2988+
"ids": Series([True, True, False]),
2989+
}
2990+
)
2991+
2992+
tm.assert_frame_equal(df, expected_df)
2993+
2994+
29732995
class TestLocSeries:
29742996
@pytest.mark.parametrize("val,expected", [(2**63 - 1, 3), (2**63, 4)])
29752997
def test_loc_uint64(self, val, expected):

0 commit comments

Comments
 (0)