Commit 20d5b1c
authored
BUG: pivot_table with overlapping values (#61293)
* modified: pandas/tests/reshape/test_pivot_multilevel.py
- Added two tests, :func:`test_pivot_table_values_in_columns` and :func:`test_pivot_table_values_in_index`, to ensure that the `values` param is still used when the argument is shared between the `columns` and `values` params, and `index` and `values` params.
* modified: pandas/core/reshape/pivot.py
- Added condition to :func:`__internal_pivot_table` to aggregate `values` explicitly if `values` were passed, otherwise aggregate all remaining columns. This allows the tests :func:`test_pivot_table_values_in_columns` and :func:`test_pivot_table_values_in_index` in test_pivot_multilevel.py to pass.
* modified: pandas/tests/reshape/test_pivot.py
- Added test :func:`test_pivot_table_values_as_two_params` to test that the updates in pivot.py result in expected results, satisfying GH issue #57876.
* modified: pandas/tests/reshape/test_pivot.py
- Added GH issue comment to test :func:`test_pivot_table_values_as_two_params`.
* modified: pandas/tests/reshape/test_pivot_multilevel.py
- Combined tests :func:`test_pivot_table_values_in_columns` and :func:`test_pivot_table_values_in_index` into a single parametrized test, :func:`test_pivot_table_multiindex_values_as_two_params` to reduce duplicate setup code.
* modified: pandas/tests/reshape/test_pivot_multilevel.py
- Added GH issue #61292 as comment to test :func:`test_pivot_table_multiindex_values_as_two_params`.
* modified: pandas/core/reshape/pivot.py
- Simplified proposed logic in :func:`__internal_pivot_table`.
* modified: pandas/core/reshape/pivot.py
- Added GH issue numbers to new logic in :func:`__internal_pivot_table`.
* modified: pandas/core/reshape/pivot.py
- Added ignore-comment to silence mypy error in :func:`__internal_pivot_table`.
- Added TODO-comment stating that the :meth:`DataFrameGroupBy.__getitem__` should be overloaded to match the pandas-stubs type declarations, informing mypy that the type is correct given `values` is a list.
* modified: doc/source/whatsnew/v3.0.0.rst
- Added pivot_table bug to Bugs/Reshaping section referencing issues #57876 and #61292.
* modified: pandas/core/reshape/pivot.py
- Moved and simplified mypy comment per feedback.
* modified: pandas/core/reshape/pivot.py
- Removed comment about explicit aggregation per feedback.
* modified: pandas/tests/reshape/test_pivot.py
- Removed param names and updated `argnames` arg per feedback in parametrized marker.
* modified: pandas/tests/reshape/test_pivot.py
- Removed param names in favor of implicit args per feedback.
* modified: pandas/tests/reshape/test_pivot_multilevel.py
- Removed param names and updated arg for `argnames` in parametrized marker per feedback.
* modified: pandas/tests/reshape/test_pivot_multilevel.py
- Reduced `expected` assignments from two to one per feedback.
* modified: pandas/tests/reshape/test_pivot_multilevel.py
- Removed param names in favor of implicit args per feedback.
* modified: pandas/tests/reshape/test_pivot_multilevel.py
- Moved e_data, e_index, and e_cols to parametrized marker instead of declaring inside the test :func:`test_pivot_table_multiindex_values_as_two_params`.
* modified: pandas/tests/reshape/test_pivot.py
- Moved `expected` setup to parametrized marker instead of in the test :meth:`TestPivotTable.test_pivot_table_values_as_two_params`.
* modified: pandas/tests/reshape/test_pivot.py
- Removed walrus operator declarations in parametrized marker for test :meth:TestPivotTable.test_pivot_table_values_as_two_params`. Appears related to this mypy issue -> python/mypy#17377.
* modified: pandas/tests/reshape/test_pivot_multilevel.py
- Removed walrus operator declarations as I'm sure mypy would raise an issue with it given that it did in test_pivot.py (see commit 52cf560).1 parent 1ac8552 commit 20d5b1c
File tree
4 files changed
+95
-0
lines changed- doc/source/whatsnew
- pandas
- core/reshape
- tests/reshape
4 files changed
+95
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
835 | 835 | | |
836 | 836 | | |
837 | 837 | | |
| 838 | + | |
838 | 839 | | |
839 | 840 | | |
840 | 841 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
336 | 336 | | |
337 | 337 | | |
338 | 338 | | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
339 | 344 | | |
340 | 345 | | |
341 | 346 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2554 | 2554 | | |
2555 | 2555 | | |
2556 | 2556 | | |
| 2557 | + | |
| 2558 | + | |
| 2559 | + | |
| 2560 | + | |
| 2561 | + | |
| 2562 | + | |
| 2563 | + | |
| 2564 | + | |
| 2565 | + | |
| 2566 | + | |
| 2567 | + | |
| 2568 | + | |
| 2569 | + | |
| 2570 | + | |
| 2571 | + | |
| 2572 | + | |
| 2573 | + | |
| 2574 | + | |
| 2575 | + | |
| 2576 | + | |
| 2577 | + | |
| 2578 | + | |
| 2579 | + | |
| 2580 | + | |
| 2581 | + | |
| 2582 | + | |
| 2583 | + | |
| 2584 | + | |
| 2585 | + | |
| 2586 | + | |
| 2587 | + | |
| 2588 | + | |
| 2589 | + | |
| 2590 | + | |
| 2591 | + | |
| 2592 | + | |
| 2593 | + | |
| 2594 | + | |
| 2595 | + | |
| 2596 | + | |
2557 | 2597 | | |
2558 | 2598 | | |
2559 | 2599 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
250 | 250 | | |
251 | 251 | | |
252 | 252 | | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
0 commit comments