(backend)
| 93 | |
| 94 | |
| 95 | def test_subset_row_slice(backend): |
| 96 | # Case: taking a subset of the rows of a DataFrame using a slice |
| 97 | # + afterwards modifying the subset |
| 98 | _, DataFrame, _ = backend |
| 99 | df = DataFrame({"a": [1, 2, 3], "b": [4, 5, 6], "c": [0.1, 0.2, 0.3]}) |
| 100 | df_orig = df.copy() |
| 101 | |
| 102 | subset = df[1:3] |
| 103 | subset._mgr._verify_integrity() |
| 104 | |
| 105 | assert subset.columns is not df.columns |
| 106 | assert np.shares_memory(get_array(subset, "a"), get_array(df, "a")) |
| 107 | |
| 108 | subset.iloc[0, 0] = 0 |
| 109 | assert not np.shares_memory(get_array(subset, "a"), get_array(df, "a")) |
| 110 | |
| 111 | subset._mgr._verify_integrity() |
| 112 | |
| 113 | expected = DataFrame({"a": [0, 3], "b": [5, 6], "c": [0.2, 0.3]}, index=range(1, 3)) |
| 114 | tm.assert_frame_equal(subset, expected) |
| 115 | # original parent dataframe is not modified (CoW) |
| 116 | tm.assert_frame_equal(df, df_orig) |
| 117 | |
| 118 | |
| 119 | @pytest.mark.parametrize( |
nothing calls this directly
no test coverage detected