| 4484 | |
| 4485 | |
| 4486 | def test_pivot_wider(): |
| 4487 | key_names = ["width", "height"] |
| 4488 | |
| 4489 | result = pc.pivot_wider(["height", "width", "depth"], [10, None, 11]) |
| 4490 | assert result.as_py() == {} |
| 4491 | |
| 4492 | result = pc.pivot_wider(["height", "width", "depth"], [10, None, 11], |
| 4493 | key_names) |
| 4494 | assert result.as_py() == {"width": None, "height": 10} |
| 4495 | # check key order |
| 4496 | assert list(result.as_py()) == ["width", "height"] |
| 4497 | |
| 4498 | result = pc.pivot_wider(["height", "width", "depth"], [10, None, 11], |
| 4499 | key_names=key_names) |
| 4500 | assert result.as_py() == {"width": None, "height": 10} |
| 4501 | |
| 4502 | with pytest.raises(KeyError, match="Unexpected pivot key: depth"): |
| 4503 | result = pc.pivot_wider(["height", "width", "depth"], [10, None, 11], |
| 4504 | key_names=key_names, |
| 4505 | unexpected_key_behavior="raise") |
| 4506 | |
| 4507 | with pytest.raises(ValueError, match="Encountered more than one non-null value"): |
| 4508 | result = pc.pivot_wider(["height", "width", "height"], [10, None, 11], |
| 4509 | key_names=key_names) |
| 4510 | |
| 4511 | |
| 4512 | def test_winsorize(): |