Skip to content

Commit

Permalink
TST: Added test for issue 26568 (pandas-dev#42591)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex-JG3 authored and CGe0516 committed Jul 29, 2021
1 parent b10985b commit df85cdd
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions pandas/tests/reshape/test_pivot.py
Original file line number Diff line number Diff line change
Expand Up @@ -2148,6 +2148,23 @@ def test_pivot_table_sort_false(self):
)
tm.assert_frame_equal(result, expected)

def test_pivot_table_with_margins_and_numeric_columns(self):
# GH 26568
df = DataFrame([["a", "x", 1], ["a", "y", 2], ["b", "y", 3], ["b", "z", 4]])
df.columns = [10, 20, 30]

result = df.pivot_table(
index=10, columns=20, values=30, aggfunc="sum", fill_value=0, margins=True
)

expected = DataFrame([[1, 2, 0, 3], [0, 3, 4, 7], [1, 5, 4, 10]])
expected.columns = ["x", "y", "z", "All"]
expected.index = ["a", "b", "All"]
expected.columns.name = 20
expected.index.name = 10

tm.assert_frame_equal(result, expected)


class TestPivot:
def test_pivot(self):
Expand Down

0 comments on commit df85cdd

Please sign in to comment.