| 8 | |
| 9 | |
| 10 | def test_error(): |
| 11 | df = pd.DataFrame( |
| 12 | {"A": pd.Series([[0, 1, 2], np.nan, [], (3, 4)], index=list("abcd")), "B": 1} |
| 13 | ) |
| 14 | with pytest.raises( |
| 15 | ValueError, match="column must be a scalar, tuple, or list thereof" |
| 16 | ): |
| 17 | df.explode([list("AA")]) |
| 18 | |
| 19 | with pytest.raises(ValueError, match="column must be unique"): |
| 20 | df.explode(list("AA")) |
| 21 | |
| 22 | df.columns = list("AA") |
| 23 | with pytest.raises( |
| 24 | ValueError, |
| 25 | match=re.escape("DataFrame columns must be unique. Duplicate columns: ['A']"), |
| 26 | ): |
| 27 | df.explode("A") |
| 28 | |
| 29 | |
| 30 | @pytest.mark.parametrize( |