From aaecd931f9bb987087a4560880a3b6ca3d00126e Mon Sep 17 00:00:00 2001 From: Ian Thompson Date: Wed, 26 Mar 2025 11:46:39 -0500 Subject: [PATCH 01/17] modified: pandas/tests/reshape/test_pivot.py - Added test :callable:`test_pivot_table_index_and_column_keys_with_nan` to test that null index/column keys are kept when `dropna=False`, and removed when `dropna=True`. --- pandas/tests/reshape/test_pivot.py | 57 ++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/pandas/tests/reshape/test_pivot.py b/pandas/tests/reshape/test_pivot.py index 374d236c8ff39..053e6db73bb2a 100644 --- a/pandas/tests/reshape/test_pivot.py +++ b/pandas/tests/reshape/test_pivot.py @@ -2529,6 +2529,63 @@ def test_pivot_table_aggfunc_nunique_with_different_values(self): tm.assert_frame_equal(result, expected) + def test_pivot_table_index_and_column_keys_with_nan(self, dropna: bool) -> None: + """Index/column keys containing NA values depend on ``dropna``. + + Input data + ---------- + row col val + 0 NaN 0.0 0 + 1 0.0 1.0 1 + 2 1.0 2.0 2 + 3 2.0 3.0 3 + 4 3.0 NaN 4 + + ``dropna=True``: Index/column keys containing NA values will be dropped. + Expected output + --------------- + col 1.0 2.0 3.0 + row + 0.0 1.0 NaN NaN + 1.0 NaN 2.0 NaN + 2.0 NaN NaN 3.0 + + ``dropna=False``: Index/columns should exist if any non-null values. + Expected output + --------------- + col 0.0 1.0 2.0 3.0 NaN + row + 0.0 NaN 1.0 NaN NaN NaN + 1.0 NaN NaN 2.0 NaN NaN + 2.0 NaN NaN NaN 3.0 NaN + 3.0 NaN NaN NaN NaN 4.0 + NaN 0.0 NaN NaN NaN NaN + """ + data = {"row": [None, *range(4)], "col": [*range(4), None], "val": range(5)} + df = DataFrame(data) + actual = df.pivot_table(values="val", index="row", columns="col", dropna=dropna) + e_index = [None, *range(4)] + e_columns = [*range(4), None] + e_data = np.zeros(shape=(5, 5)) + e_data.fill(np.NaN) + np.fill_diagonal(a=e_data, val=range(5)) + expected = DataFrame( + data=e_data, + index=Index(data=e_index, name="row"), + columns=Index(data=e_columns, name="col"), + ).sort_index() + if dropna: + expected = ( + # Drop null index/column keys. + expected.loc[expected.index.notna(), expected.columns.notna()] + # Drop null rows. + .dropna(axis="index", how="all") + # Drop null columns. + .dropna(axis="columns", how="all") + ) + + tm.assert_frame_equal(left=actual, right=expected) + class TestPivot: def test_pivot(self): From c859b73b8bbf3b9e4bd508f945643a6d62d20cb6 Mon Sep 17 00:00:00 2001 From: Ian Thompson Date: Wed, 26 Mar 2025 11:51:35 -0500 Subject: [PATCH 02/17] modified: pandas/core/reshape/pivot.py - Updated docs for `dropna` parameter in :callable:`pivot_table`. --- pandas/core/reshape/pivot.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pandas/core/reshape/pivot.py b/pandas/core/reshape/pivot.py index cfc6f91557781..fc8cd1fd6b19c 100644 --- a/pandas/core/reshape/pivot.py +++ b/pandas/core/reshape/pivot.py @@ -102,8 +102,9 @@ def pivot_table( on the rows and columns. dropna : bool, default True Do not include columns whose entries are all NaN. If True, - rows with a NaN value in any column will be omitted before - computing margins. + - rows with a NaN value in any column will be omitted before computing margins + - index/column keys containing NA values will be dropped (see ``dropna`` + parameter in ``pandas.DataFrame.groupby``) margins_name : str, default 'All' Name of the row / column that will contain the totals when margins is True. From 9b796fede8b89efaf047988a2d0b722e1deffb62 Mon Sep 17 00:00:00 2001 From: Ian Thompson Date: Wed, 26 Mar 2025 12:20:39 -0500 Subject: [PATCH 03/17] modified: pandas/tests/reshape/test_pivot.py - Replaced `np.NaN` with `np.nan` to pass failing tests on CI build. --- pandas/tests/reshape/test_pivot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/reshape/test_pivot.py b/pandas/tests/reshape/test_pivot.py index 053e6db73bb2a..4ffeea32d9f88 100644 --- a/pandas/tests/reshape/test_pivot.py +++ b/pandas/tests/reshape/test_pivot.py @@ -2567,7 +2567,7 @@ def test_pivot_table_index_and_column_keys_with_nan(self, dropna: bool) -> None: e_index = [None, *range(4)] e_columns = [*range(4), None] e_data = np.zeros(shape=(5, 5)) - e_data.fill(np.NaN) + e_data.fill(np.nan) np.fill_diagonal(a=e_data, val=range(5)) expected = DataFrame( data=e_data, From dd4326c2db1133883320772cb89c42b73733e94c Mon Sep 17 00:00:00 2001 From: Ian Thompson Date: Wed, 26 Mar 2025 13:06:59 -0500 Subject: [PATCH 04/17] modified: pandas/core/reshape/pivot.py - Added comma and period to `dropna` parameter in :callable:`pivot_table` to pass docstring validation hook in CI build. --- pandas/core/reshape/pivot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/core/reshape/pivot.py b/pandas/core/reshape/pivot.py index fc8cd1fd6b19c..049a98fe236d8 100644 --- a/pandas/core/reshape/pivot.py +++ b/pandas/core/reshape/pivot.py @@ -102,9 +102,9 @@ def pivot_table( on the rows and columns. dropna : bool, default True Do not include columns whose entries are all NaN. If True, - - rows with a NaN value in any column will be omitted before computing margins + - rows with a NaN value in any column will be omitted before computing margins, - index/column keys containing NA values will be dropped (see ``dropna`` - parameter in ``pandas.DataFrame.groupby``) + parameter in ``pandas.DataFrame.groupby``). margins_name : str, default 'All' Name of the row / column that will contain the totals when margins is True. From 64d4f0d871e682eac43ced013ea6919e2c3749ee Mon Sep 17 00:00:00 2001 From: Ian Thompson Date: Fri, 28 Mar 2025 14:21:42 -0500 Subject: [PATCH 05/17] modified: pandas/core/reshape/pivot.py - Updated reference link to `pandas.DataFrame.groupby` with :method: syntax in the :callable:`pivot_table` param `dropna` docstring. --- pandas/core/reshape/pivot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/reshape/pivot.py b/pandas/core/reshape/pivot.py index 049a98fe236d8..a9aa09630e0f2 100644 --- a/pandas/core/reshape/pivot.py +++ b/pandas/core/reshape/pivot.py @@ -104,7 +104,7 @@ def pivot_table( Do not include columns whose entries are all NaN. If True, - rows with a NaN value in any column will be omitted before computing margins, - index/column keys containing NA values will be dropped (see ``dropna`` - parameter in ``pandas.DataFrame.groupby``). + parameter in :method:``DataFrame.groupby``). margins_name : str, default 'All' Name of the row / column that will contain the totals when margins is True. From e19bf3c157ab79023891c451e5f5edea27580f22 Mon Sep 17 00:00:00 2001 From: Ian Thompson Date: Fri, 28 Mar 2025 14:23:32 -0500 Subject: [PATCH 06/17] modified: pandas/core/reshape/pivot.py - Replaced "NaN" with "NA" per request from @rhshadrach in comment. --- pandas/core/reshape/pivot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/reshape/pivot.py b/pandas/core/reshape/pivot.py index a9aa09630e0f2..1b4f8664ea176 100644 --- a/pandas/core/reshape/pivot.py +++ b/pandas/core/reshape/pivot.py @@ -102,7 +102,7 @@ def pivot_table( on the rows and columns. dropna : bool, default True Do not include columns whose entries are all NaN. If True, - - rows with a NaN value in any column will be omitted before computing margins, + - rows with a NA value in any column will be omitted before computing margins, - index/column keys containing NA values will be dropped (see ``dropna`` parameter in :method:``DataFrame.groupby``). margins_name : str, default 'All' From fb7478fcc21b7f538b0cd76a4784bdc0eec95740 Mon Sep 17 00:00:00 2001 From: Ian Thompson Date: Fri, 28 Mar 2025 14:28:12 -0500 Subject: [PATCH 07/17] modified: pandas/core/frame.py - Updated value of :attr:`DataFrame._shared_docs["pivot_table"]` to include updated docstring from `pandas.core.reshape.pivot.pivot_table`. --- pandas/core/frame.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 8f65277f660f7..7ed72e1611d1b 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -9347,8 +9347,10 @@ def pivot( on the rows and columns. dropna : bool, default True Do not include columns whose entries are all NaN. If True, - rows with a NaN value in any column will be omitted before - computing margins. + - rows with a NA value in any column will be omitted before computing + margins, + - index/column keys containing NA values will be dropped (see ``dropna`` + parameter in :method:``DataFrame.groupby``). margins_name : str, default 'All' Name of the row / column that will contain the totals when margins is True. From fc0a75f87222ac00a275e07bfcc6720dfcab7fa7 Mon Sep 17 00:00:00 2001 From: Ian Thompson Date: Sun, 30 Mar 2025 19:04:14 -0500 Subject: [PATCH 08/17] modified: pandas/core/reshape/pivot.py - Updated spelling of :method: to :meth: per comment feedback. --- pandas/core/reshape/pivot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/reshape/pivot.py b/pandas/core/reshape/pivot.py index 1b4f8664ea176..944064ad1e953 100644 --- a/pandas/core/reshape/pivot.py +++ b/pandas/core/reshape/pivot.py @@ -104,7 +104,7 @@ def pivot_table( Do not include columns whose entries are all NaN. If True, - rows with a NA value in any column will be omitted before computing margins, - index/column keys containing NA values will be dropped (see ``dropna`` - parameter in :method:``DataFrame.groupby``). + parameter in :meth:``DataFrame.groupby``). margins_name : str, default 'All' Name of the row / column that will contain the totals when margins is True. From 5f748430f9fd4a9d5b3a23d452ce8358a05f8058 Mon Sep 17 00:00:00 2001 From: Ian Thompson Date: Sun, 30 Mar 2025 19:06:56 -0500 Subject: [PATCH 09/17] modified: pandas/core/frame.py - Updated shared docs replacing :method: with :meth: per comment feedback. --- pandas/core/frame.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 7ed72e1611d1b..c594b7213063a 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -9350,7 +9350,7 @@ def pivot( - rows with a NA value in any column will be omitted before computing margins, - index/column keys containing NA values will be dropped (see ``dropna`` - parameter in :method:``DataFrame.groupby``). + parameter in :meth:``DataFrame.groupby``). margins_name : str, default 'All' Name of the row / column that will contain the totals when margins is True. From b26a9077f01b0b1622b3df13a95c319e6a9a5a77 Mon Sep 17 00:00:00 2001 From: Ian Thompson Date: Sun, 30 Mar 2025 19:16:10 -0500 Subject: [PATCH 10/17] modified: pandas/tests/reshape/test_pivot.py - Removed docstring for `test_pivot_table_index_and_column_keys_with_nan` per comment feedback. --- pandas/tests/reshape/test_pivot.py | 31 ------------------------------ 1 file changed, 31 deletions(-) diff --git a/pandas/tests/reshape/test_pivot.py b/pandas/tests/reshape/test_pivot.py index 4ffeea32d9f88..1578420401f96 100644 --- a/pandas/tests/reshape/test_pivot.py +++ b/pandas/tests/reshape/test_pivot.py @@ -2530,37 +2530,6 @@ def test_pivot_table_aggfunc_nunique_with_different_values(self): tm.assert_frame_equal(result, expected) def test_pivot_table_index_and_column_keys_with_nan(self, dropna: bool) -> None: - """Index/column keys containing NA values depend on ``dropna``. - - Input data - ---------- - row col val - 0 NaN 0.0 0 - 1 0.0 1.0 1 - 2 1.0 2.0 2 - 3 2.0 3.0 3 - 4 3.0 NaN 4 - - ``dropna=True``: Index/column keys containing NA values will be dropped. - Expected output - --------------- - col 1.0 2.0 3.0 - row - 0.0 1.0 NaN NaN - 1.0 NaN 2.0 NaN - 2.0 NaN NaN 3.0 - - ``dropna=False``: Index/columns should exist if any non-null values. - Expected output - --------------- - col 0.0 1.0 2.0 3.0 NaN - row - 0.0 NaN 1.0 NaN NaN NaN - 1.0 NaN NaN 2.0 NaN NaN - 2.0 NaN NaN NaN 3.0 NaN - 3.0 NaN NaN NaN NaN 4.0 - NaN 0.0 NaN NaN NaN NaN - """ data = {"row": [None, *range(4)], "col": [*range(4), None], "val": range(5)} df = DataFrame(data) actual = df.pivot_table(values="val", index="row", columns="col", dropna=dropna) From 892a1a25944dc73930a9f19682616e0bf50d4969 Mon Sep 17 00:00:00 2001 From: Ian Thompson Date: Sun, 30 Mar 2025 19:22:27 -0500 Subject: [PATCH 11/17] modified: pandas/tests/reshape/test_pivot.py - Renamed `actual` -> `result` per comment feedback. --- pandas/tests/reshape/test_pivot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/tests/reshape/test_pivot.py b/pandas/tests/reshape/test_pivot.py index 1578420401f96..be9ae4933320e 100644 --- a/pandas/tests/reshape/test_pivot.py +++ b/pandas/tests/reshape/test_pivot.py @@ -2532,7 +2532,7 @@ def test_pivot_table_aggfunc_nunique_with_different_values(self): def test_pivot_table_index_and_column_keys_with_nan(self, dropna: bool) -> None: data = {"row": [None, *range(4)], "col": [*range(4), None], "val": range(5)} df = DataFrame(data) - actual = df.pivot_table(values="val", index="row", columns="col", dropna=dropna) + result = df.pivot_table(values="val", index="row", columns="col", dropna=dropna) e_index = [None, *range(4)] e_columns = [*range(4), None] e_data = np.zeros(shape=(5, 5)) @@ -2553,7 +2553,7 @@ def test_pivot_table_index_and_column_keys_with_nan(self, dropna: bool) -> None: .dropna(axis="columns", how="all") ) - tm.assert_frame_equal(left=actual, right=expected) + tm.assert_frame_equal(left=result, right=expected) class TestPivot: From f2e4caee6717260670c0e8153f87ec2a9f289015 Mon Sep 17 00:00:00 2001 From: Ian Thompson Date: Sun, 30 Mar 2025 19:26:55 -0500 Subject: [PATCH 12/17] modified: pandas/tests/reshape/test_pivot.py - Removed type hints for `test_pivot_table_index_and_column_keys_with_nan` per comment feedback. --- pandas/tests/reshape/test_pivot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/reshape/test_pivot.py b/pandas/tests/reshape/test_pivot.py index be9ae4933320e..44e4dc549545e 100644 --- a/pandas/tests/reshape/test_pivot.py +++ b/pandas/tests/reshape/test_pivot.py @@ -2529,7 +2529,7 @@ def test_pivot_table_aggfunc_nunique_with_different_values(self): tm.assert_frame_equal(result, expected) - def test_pivot_table_index_and_column_keys_with_nan(self, dropna: bool) -> None: + def test_pivot_table_index_and_column_keys_with_nan(self, dropna): data = {"row": [None, *range(4)], "col": [*range(4), None], "val": range(5)} df = DataFrame(data) result = df.pivot_table(values="val", index="row", columns="col", dropna=dropna) From 17a246b8c604948c523c79445a10efba26327854 Mon Sep 17 00:00:00 2001 From: Ian Thompson Date: Sun, 30 Mar 2025 19:59:06 -0500 Subject: [PATCH 13/17] modified: pandas/tests/reshape/test_pivot.py - Removed data manipulations from `expected` to prevent dependencies on other pandas methods. --- pandas/tests/reshape/test_pivot.py | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/pandas/tests/reshape/test_pivot.py b/pandas/tests/reshape/test_pivot.py index 44e4dc549545e..c7f5cf4274910 100644 --- a/pandas/tests/reshape/test_pivot.py +++ b/pandas/tests/reshape/test_pivot.py @@ -2533,25 +2533,22 @@ def test_pivot_table_index_and_column_keys_with_nan(self, dropna): data = {"row": [None, *range(4)], "col": [*range(4), None], "val": range(5)} df = DataFrame(data) result = df.pivot_table(values="val", index="row", columns="col", dropna=dropna) - e_index = [None, *range(4)] - e_columns = [*range(4), None] - e_data = np.zeros(shape=(5, 5)) - e_data.fill(np.nan) - np.fill_diagonal(a=e_data, val=range(5)) + e_axis = [*range(4), None] + nan = np.nan + e_data = [ + [nan, 1.0, nan, nan, nan], + [nan, nan, 2.0, nan, nan], + [nan, nan, nan, 3.0, nan], + [nan, nan, nan, nan, 4.0], + [0.0, nan, nan, nan, nan], + ] expected = DataFrame( data=e_data, - index=Index(data=e_index, name="row"), - columns=Index(data=e_columns, name="col"), - ).sort_index() + index=Index(data=e_axis, name="row"), + columns=Index(data=e_axis, name="col"), + ) if dropna: - expected = ( - # Drop null index/column keys. - expected.loc[expected.index.notna(), expected.columns.notna()] - # Drop null rows. - .dropna(axis="index", how="all") - # Drop null columns. - .dropna(axis="columns", how="all") - ) + expected = expected.loc[[0, 1, 2], [1, 2, 3]] tm.assert_frame_equal(left=result, right=expected) From 0edffc253a3de2cf602ded2e9bcbb2ae5c7491b0 Mon Sep 17 00:00:00 2001 From: Ian Thompson Date: Sun, 30 Mar 2025 20:00:55 -0500 Subject: [PATCH 14/17] modified: pandas/tests/reshape/test_pivot.py - Added comment with GitHub issue reference number. --- pandas/tests/reshape/test_pivot.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pandas/tests/reshape/test_pivot.py b/pandas/tests/reshape/test_pivot.py index c7f5cf4274910..46eee13755b2d 100644 --- a/pandas/tests/reshape/test_pivot.py +++ b/pandas/tests/reshape/test_pivot.py @@ -2530,6 +2530,7 @@ def test_pivot_table_aggfunc_nunique_with_different_values(self): tm.assert_frame_equal(result, expected) def test_pivot_table_index_and_column_keys_with_nan(self, dropna): + # GH#61113 data = {"row": [None, *range(4)], "col": [*range(4), None], "val": range(5)} df = DataFrame(data) result = df.pivot_table(values="val", index="row", columns="col", dropna=dropna) From bc66c1a44d66ce77d362d69afed62dacbbf2dd85 Mon Sep 17 00:00:00 2001 From: Ian Thompson Date: Sun, 30 Mar 2025 20:02:36 -0500 Subject: [PATCH 15/17] modified: pandas/core/frame.py - Updated _shared_docs["pivot_table"] to match docstring in pandas/core/reshape/pivot.py. modified: pandas/core/reshape/pivot.py - Updated `dropna` param docstring in `pivot_table` so the dashes convert to a bulleted list. --- pandas/core/frame.py | 4 ++-- pandas/core/reshape/pivot.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index c594b7213063a..b923fdd3d4797 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -9347,9 +9347,9 @@ def pivot( on the rows and columns. dropna : bool, default True Do not include columns whose entries are all NaN. If True, - - rows with a NA value in any column will be omitted before computing + - rows with a NA value in any column will be omitted before computing margins, - - index/column keys containing NA values will be dropped (see ``dropna`` + - index/column keys containing NA values will be dropped (see ``dropna`` parameter in :meth:``DataFrame.groupby``). margins_name : str, default 'All' Name of the row / column that will contain the totals diff --git a/pandas/core/reshape/pivot.py b/pandas/core/reshape/pivot.py index 944064ad1e953..ab91d243efc49 100644 --- a/pandas/core/reshape/pivot.py +++ b/pandas/core/reshape/pivot.py @@ -102,8 +102,8 @@ def pivot_table( on the rows and columns. dropna : bool, default True Do not include columns whose entries are all NaN. If True, - - rows with a NA value in any column will be omitted before computing margins, - - index/column keys containing NA values will be dropped (see ``dropna`` + - rows with a NA value in any column will be omitted before computing margins, + - index/column keys containing NA values will be dropped (see ``dropna`` parameter in :meth:``DataFrame.groupby``). margins_name : str, default 'All' Name of the row / column that will contain the totals From 1a82d2a9930a8041d6e0f0992390c8d42d7b23be Mon Sep 17 00:00:00 2001 From: Ian Thompson Date: Mon, 31 Mar 2025 10:25:37 -0500 Subject: [PATCH 16/17] modified: pandas/core/frame.py - Updated dropna param description in `_shared_docs["pivot_table"]` to use bulleted list similar to `parse_dates` param description in `pandas.io.parsers.readers._doc_read_csv_and_table`. modified: pandas/core/reshape/pivot.py - Updated docstring for `dropna` param in :func:`pivot_table` to use bulleted list similar to `parse_dates` param description in `pandas.io.parsers.readers._doc_read_csv_and_table`. --- pandas/core/frame.py | 10 ++++++---- pandas/core/reshape/pivot.py | 8 +++++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index b923fdd3d4797..11eec18dd0c04 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -9347,10 +9347,12 @@ def pivot( on the rows and columns. dropna : bool, default True Do not include columns whose entries are all NaN. If True, - - rows with a NA value in any column will be omitted before computing - margins, - - index/column keys containing NA values will be dropped (see ``dropna`` - parameter in :meth:``DataFrame.groupby``). + + * rows with a NA value in any column will be omitted before computing + margins, + * index/column keys containing NA values will be dropped (see ``dropna`` + parameter in :meth:``DataFrame.groupby``). + margins_name : str, default 'All' Name of the row / column that will contain the totals when margins is True. diff --git a/pandas/core/reshape/pivot.py b/pandas/core/reshape/pivot.py index ab91d243efc49..63470cf2af990 100644 --- a/pandas/core/reshape/pivot.py +++ b/pandas/core/reshape/pivot.py @@ -102,9 +102,11 @@ def pivot_table( on the rows and columns. dropna : bool, default True Do not include columns whose entries are all NaN. If True, - - rows with a NA value in any column will be omitted before computing margins, - - index/column keys containing NA values will be dropped (see ``dropna`` - parameter in :meth:``DataFrame.groupby``). + + * rows with a NA value in any column will be omitted before computing margins, + * index/column keys containing NA values will be dropped (see ``dropna`` + parameter in :meth:``DataFrame.groupby``). + margins_name : str, default 'All' Name of the row / column that will contain the totals when margins is True. From 684ab122ca71f29df78257ce8abfca98a56e34ba Mon Sep 17 00:00:00 2001 From: Ian Thompson Date: Mon, 31 Mar 2025 20:35:23 -0500 Subject: [PATCH 17/17] modified: pandas/core/frame.py - Updated `_shared_docs["pivot_table"]` value per comments. modified: pandas/core/reshape/pivot.py - Updated `dropna` param docstring in :func:`pivot_table` per comments. --- pandas/core/frame.py | 4 ++-- pandas/core/reshape/pivot.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 11eec18dd0c04..dea246bcd1cf8 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -9348,10 +9348,10 @@ def pivot( dropna : bool, default True Do not include columns whose entries are all NaN. If True, - * rows with a NA value in any column will be omitted before computing + * rows with an NA value in any column will be omitted before computing margins, * index/column keys containing NA values will be dropped (see ``dropna`` - parameter in :meth:``DataFrame.groupby``). + parameter in :meth:`DataFrame.groupby`). margins_name : str, default 'All' Name of the row / column that will contain the totals diff --git a/pandas/core/reshape/pivot.py b/pandas/core/reshape/pivot.py index 63470cf2af990..0a8ade581dea0 100644 --- a/pandas/core/reshape/pivot.py +++ b/pandas/core/reshape/pivot.py @@ -103,7 +103,7 @@ def pivot_table( dropna : bool, default True Do not include columns whose entries are all NaN. If True, - * rows with a NA value in any column will be omitted before computing margins, + * rows with an NA value in any column will be omitted before computing margins, * index/column keys containing NA values will be dropped (see ``dropna`` parameter in :meth:``DataFrame.groupby``).