|
18 | 18 | PeriodDtype,
|
19 | 19 | )
|
20 | 20 |
|
| 21 | +import pandas as pd |
21 | 22 | from pandas import (
|
22 | 23 | Categorical,
|
23 | 24 | DataFrame,
|
@@ -792,22 +793,29 @@ def test_setitem_slice_position(self):
|
792 | 793 | tm.assert_frame_equal(df, expected)
|
793 | 794 |
|
794 | 795 | @pytest.mark.parametrize("indexer", [tm.setitem, tm.iloc])
|
795 |
| - @pytest.mark.parametrize("box", [Series, np.array, list]) |
| 796 | + @pytest.mark.parametrize("box", [Series, np.array, list, pd.array]) |
796 | 797 | @pytest.mark.parametrize("n", [1, 2, 3])
|
797 |
| - def test_setitem_broadcasting_rhs(self, n, box, indexer): |
| 798 | + def test_setitem_slice_indexer_broadcasting_rhs(self, n, box, indexer): |
798 | 799 | # GH#40440
|
799 |
| - # TODO: Add pandas array as box after GH#40933 is fixed |
800 | 800 | df = DataFrame([[1, 3, 5]] + [[2, 4, 6]] * n, columns=["a", "b", "c"])
|
801 | 801 | indexer(df)[1:] = box([10, 11, 12])
|
802 | 802 | expected = DataFrame([[1, 3, 5]] + [[10, 11, 12]] * n, columns=["a", "b", "c"])
|
803 | 803 | tm.assert_frame_equal(df, expected)
|
804 | 804 |
|
| 805 | + @pytest.mark.parametrize("box", [Series, np.array, list, pd.array]) |
| 806 | + @pytest.mark.parametrize("n", [1, 2, 3]) |
| 807 | + def test_setitem_list_indexer_broadcasting_rhs(self, n, box): |
| 808 | + # GH#40440 |
| 809 | + df = DataFrame([[1, 3, 5]] + [[2, 4, 6]] * n, columns=["a", "b", "c"]) |
| 810 | + df.iloc[list(range(1, n + 1))] = box([10, 11, 12]) |
| 811 | + expected = DataFrame([[1, 3, 5]] + [[10, 11, 12]] * n, columns=["a", "b", "c"]) |
| 812 | + tm.assert_frame_equal(df, expected) |
| 813 | + |
805 | 814 | @pytest.mark.parametrize("indexer", [tm.setitem, tm.iloc])
|
806 |
| - @pytest.mark.parametrize("box", [Series, np.array, list]) |
| 815 | + @pytest.mark.parametrize("box", [Series, np.array, list, pd.array]) |
807 | 816 | @pytest.mark.parametrize("n", [1, 2, 3])
|
808 |
| - def test_setitem_broadcasting_rhs_mixed_dtypes(self, n, box, indexer): |
| 817 | + def test_setitem_slice_broadcasting_rhs_mixed_dtypes(self, n, box, indexer): |
809 | 818 | # GH#40440
|
810 |
| - # TODO: Add pandas array as box after GH#40933 is fixed |
811 | 819 | df = DataFrame(
|
812 | 820 | [[1, 3, 5], ["x", "y", "z"]] + [[2, 4, 6]] * n, columns=["a", "b", "c"]
|
813 | 821 | )
|
|
0 commit comments