From c3d6a2b1a49d959c61c12427883578bf535085b2 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Thu, 9 Jan 2020 10:11:13 +0530 Subject: [PATCH 01/22] added missing fill_na parameter --- pandas/core/reshape/reshape.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/reshape/reshape.py b/pandas/core/reshape/reshape.py index e654685d24d9d..fa83db3643f45 100644 --- a/pandas/core/reshape/reshape.py +++ b/pandas/core/reshape/reshape.py @@ -360,7 +360,7 @@ def _unstack_multiple(data, clocs, fill_value=None): result = data for i in range(len(clocs)): val = clocs[i] - result = result.unstack(val) + result = result.unstack(val,fill_value) clocs = [v if i > v else v - 1 for v in clocs] return result From a780a1842737af125bb94457cbc13c81ce2237d7 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Thu, 9 Jan 2020 16:36:43 +0530 Subject: [PATCH 02/22] BUG: fill_value ignored for multindex unstack (#30740) --- pandas/core/reshape/reshape.py | 2 +- pandas/tests/reshape/test_reshape.py | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/pandas/core/reshape/reshape.py b/pandas/core/reshape/reshape.py index e654685d24d9d..3584f0a633ce0 100644 --- a/pandas/core/reshape/reshape.py +++ b/pandas/core/reshape/reshape.py @@ -360,7 +360,7 @@ def _unstack_multiple(data, clocs, fill_value=None): result = data for i in range(len(clocs)): val = clocs[i] - result = result.unstack(val) + result = result.unstack(val, fill_value) clocs = [v if i > v else v - 1 for v in clocs] return result diff --git a/pandas/tests/reshape/test_reshape.py b/pandas/tests/reshape/test_reshape.py index e2c6f7d1c8feb..38261232915cc 100644 --- a/pandas/tests/reshape/test_reshape.py +++ b/pandas/tests/reshape/test_reshape.py @@ -651,3 +651,22 @@ def test_preserve_categorical_dtype(self): result = make_axis_dummies(df, transform=lambda x: x) tm.assert_frame_equal(result, expected) + + +class TestMultiIndexReshape: + def test_unstacking_multi_index_df(self): + # BUG: 30740 + df = pd.DataFrame( + { + "name": ["Alice", "Bob"], + "score": [9.5, 8], + "employed": [False, True], + "kids": [0, 0], + "gender": ["female", "male"], + } + ) + df = df.set_index(["name", "employed", "kids", "gender"]) + df = df.unstack(["gender"], fill_value=0) + expected = df.unstack("employed", fill_value=0).unstack("kids", fill_value=0) + result = df.unstack(["employed", "kids"], fill_value=0) + tm.assert_frame_equal(result, expected) From 76931e850c53149843797f7195d84563382d8cde Mon Sep 17 00:00:00 2001 From: Tanmay Date: Thu, 9 Jan 2020 16:49:42 +0530 Subject: [PATCH 03/22] BUG : #30740 --- pandas/tests/reshape/test_reshape.py | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/pandas/tests/reshape/test_reshape.py b/pandas/tests/reshape/test_reshape.py index 38261232915cc..7bd5060a72f99 100644 --- a/pandas/tests/reshape/test_reshape.py +++ b/pandas/tests/reshape/test_reshape.py @@ -631,28 +631,6 @@ def test_reshaping_multi_index_categorical(self): ) tm.assert_frame_equal(result, expected) - -class TestMakeAxisDummies: - def test_preserve_categorical_dtype(self): - # GH13854 - for ordered in [False, True]: - cidx = pd.CategoricalIndex(list("xyz"), ordered=ordered) - midx = pd.MultiIndex(levels=[["a"], cidx], codes=[[0, 0], [0, 1]]) - df = DataFrame([[10, 11]], index=midx) - - expected = DataFrame( - [[1.0, 0.0, 0.0], [0.0, 1.0, 0.0]], index=midx, columns=cidx - ) - - from pandas.core.reshape.reshape import make_axis_dummies - - result = make_axis_dummies(df) - tm.assert_frame_equal(result, expected) - - result = make_axis_dummies(df, transform=lambda x: x) - tm.assert_frame_equal(result, expected) - - class TestMultiIndexReshape: def test_unstacking_multi_index_df(self): # BUG: 30740 From d45d1760e8378c50e05db3a8f4c471cb5e88523d Mon Sep 17 00:00:00 2001 From: Tanmay Daripa Date: Thu, 9 Jan 2020 17:35:09 +0530 Subject: [PATCH 04/22] Update pandas/tests/reshape/test_reshape.py Co-Authored-By: Simon Hawkins --- pandas/tests/reshape/test_reshape.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/reshape/test_reshape.py b/pandas/tests/reshape/test_reshape.py index 92213e5903ef0..e8c852a6c2341 100644 --- a/pandas/tests/reshape/test_reshape.py +++ b/pandas/tests/reshape/test_reshape.py @@ -648,7 +648,7 @@ def test_reshaping_multi_index_categorical(self): class TestMultiIndexReshape: def test_unstacking_multi_index_df(self): - # BUG: 30740 + # see gh-30740 df = pd.DataFrame( { "name": ["Alice", "Bob"], From efc579d512390e196655a7e9dfe1be12400721e1 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Thu, 9 Jan 2020 19:11:26 +0530 Subject: [PATCH 05/22] BUG: #30740 moved test to tests/frame/test_reshape.py --- pandas/tests/frame/test_reshape.py | 19 +++++++++++++++++++ pandas/tests/reshape/test_reshape.py | 1 + 2 files changed, 20 insertions(+) diff --git a/pandas/tests/frame/test_reshape.py b/pandas/tests/frame/test_reshape.py index b77d3029a5446..e8d52be8aa0aa 100644 --- a/pandas/tests/frame/test_reshape.py +++ b/pandas/tests/frame/test_reshape.py @@ -1128,3 +1128,22 @@ def test_stack_timezone_aware_values(): ), ) tm.assert_series_equal(result, expected) + + +class TestMultiIndexReshape: + def test_unstacking_multi_index_df(self): + # BUG: 30740 + df = pd.DataFrame( + { + "name": ["Alice", "Bob"], + "score": [9.5, 8], + "employed": [False, True], + "kids": [0, 0], + "gender": ["female", "male"], + } + ) + df = df.set_index(["name", "employed", "kids", "gender"]) + df = df.unstack(["gender"], fill_value=0) + expected = df.unstack("employed", fill_value=0).unstack("kids", fill_value=0) + result = df.unstack(["employed", "kids"], fill_value=0) + tm.assert_frame_equal(result, expected) diff --git a/pandas/tests/reshape/test_reshape.py b/pandas/tests/reshape/test_reshape.py index 92213e5903ef0..fca92485ff300 100644 --- a/pandas/tests/reshape/test_reshape.py +++ b/pandas/tests/reshape/test_reshape.py @@ -646,6 +646,7 @@ def test_reshaping_multi_index_categorical(self): ) tm.assert_frame_equal(result, expected) + class TestMultiIndexReshape: def test_unstacking_multi_index_df(self): # BUG: 30740 From 1c4632a5eba10e24d5f43f2781997737967118e0 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Thu, 9 Jan 2020 19:13:38 +0530 Subject: [PATCH 06/22] BUG: #30740 added to whatsnew --- doc/source/whatsnew/v0.25.3.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/source/whatsnew/v0.25.3.rst b/doc/source/whatsnew/v0.25.3.rst index f73a3f956f42e..4d4a540584912 100644 --- a/doc/source/whatsnew/v0.25.3.rst +++ b/doc/source/whatsnew/v0.25.3.rst @@ -10,6 +10,7 @@ including other versions of pandas. Bug fixes ~~~~~~~~~ +- Bug in missing fill_na parameter to DataFrame.unstack() with list of levels (:issue:`30740`) Groupby/resample/rolling ^^^^^^^^^^^^^^^^^^^^^^^^ From e1eb1584763095fd77a90769bf2a63aeb184770d Mon Sep 17 00:00:00 2001 From: Tanmay Date: Thu, 9 Jan 2020 19:16:31 +0530 Subject: [PATCH 07/22] BUG: #30740 added gh to comment --- pandas/tests/frame/test_reshape.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/frame/test_reshape.py b/pandas/tests/frame/test_reshape.py index e8d52be8aa0aa..5bef8d70b6ca4 100644 --- a/pandas/tests/frame/test_reshape.py +++ b/pandas/tests/frame/test_reshape.py @@ -1132,7 +1132,7 @@ def test_stack_timezone_aware_values(): class TestMultiIndexReshape: def test_unstacking_multi_index_df(self): - # BUG: 30740 + # BUG: gh-30740 df = pd.DataFrame( { "name": ["Alice", "Bob"], From 001845154b5e560db81e26ed42e6f786067194d4 Mon Sep 17 00:00:00 2001 From: Tanmay Daripa Date: Thu, 9 Jan 2020 19:28:56 +0530 Subject: [PATCH 08/22] BUG #30740 moved to test/frames/test_reshape.py --- pandas/tests/reshape/test_reshape.py | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/pandas/tests/reshape/test_reshape.py b/pandas/tests/reshape/test_reshape.py index a2bce064aff88..f25291f4aef12 100644 --- a/pandas/tests/reshape/test_reshape.py +++ b/pandas/tests/reshape/test_reshape.py @@ -645,22 +645,3 @@ def test_reshaping_multi_index_categorical(self): index=dti.rename("major"), ) tm.assert_frame_equal(result, expected) - - -class TestMultiIndexReshape: - def test_unstacking_multi_index_df(self): - # see gh-30740 - df = pd.DataFrame( - { - "name": ["Alice", "Bob"], - "score": [9.5, 8], - "employed": [False, True], - "kids": [0, 0], - "gender": ["female", "male"], - } - ) - df = df.set_index(["name", "employed", "kids", "gender"]) - df = df.unstack(["gender"], fill_value=0) - expected = df.unstack("employed", fill_value=0).unstack("kids", fill_value=0) - result = df.unstack(["employed", "kids"], fill_value=0) - tm.assert_frame_equal(result, expected) From dcb8a3bebffd14df5ea0793caa356e638e98edee Mon Sep 17 00:00:00 2001 From: Tanmay Date: Thu, 9 Jan 2020 19:40:51 +0530 Subject: [PATCH 09/22] BUG #30740 moved bug doc to v1.0.0 --- doc/source/whatsnew/v1.0.0.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/source/whatsnew/v1.0.0.rst b/doc/source/whatsnew/v1.0.0.rst index 11a6f2628ac52..b172b385761c4 100755 --- a/doc/source/whatsnew/v1.0.0.rst +++ b/doc/source/whatsnew/v1.0.0.rst @@ -1039,6 +1039,7 @@ Reshaping - Dtypes are now preserved when transposing a ``DataFrame`` where each column is the same extension dtype (:issue:`30091`) - Bug in :func:`merge_asof` merging on a tz-aware ``left_index`` and ``right_on`` a tz-aware column (:issue:`29864`) - Improved error message and docstring in :func:`cut` and :func:`qcut` when `labels=True` (:issue:`13318`) +- Bug in missing fill_na parameter to DataFrame.unstack() with list of levels (:issue:`30740`) Sparse ^^^^^^ From c984d5aac813dfef0aa1190984c5da1933d03ec3 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Thu, 9 Jan 2020 19:45:00 +0530 Subject: [PATCH 10/22] BUG: #30740 removed class for tests --- pandas/tests/frame/test_reshape.py | 33 +++++++++++++++--------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/pandas/tests/frame/test_reshape.py b/pandas/tests/frame/test_reshape.py index 5bef8d70b6ca4..e5b75f95081b9 100644 --- a/pandas/tests/frame/test_reshape.py +++ b/pandas/tests/frame/test_reshape.py @@ -1130,20 +1130,19 @@ def test_stack_timezone_aware_values(): tm.assert_series_equal(result, expected) -class TestMultiIndexReshape: - def test_unstacking_multi_index_df(self): - # BUG: gh-30740 - df = pd.DataFrame( - { - "name": ["Alice", "Bob"], - "score": [9.5, 8], - "employed": [False, True], - "kids": [0, 0], - "gender": ["female", "male"], - } - ) - df = df.set_index(["name", "employed", "kids", "gender"]) - df = df.unstack(["gender"], fill_value=0) - expected = df.unstack("employed", fill_value=0).unstack("kids", fill_value=0) - result = df.unstack(["employed", "kids"], fill_value=0) - tm.assert_frame_equal(result, expected) +def test_unstacking_multi_index_df(self): + # BUG: gh-30740 + df = pd.DataFrame( + { + "name": ["Alice", "Bob"], + "score": [9.5, 8], + "employed": [False, True], + "kids": [0, 0], + "gender": ["female", "male"], + } + ) + df = df.set_index(["name", "employed", "kids", "gender"]) + df = df.unstack(["gender"], fill_value=0) + expected = df.unstack("employed", fill_value=0).unstack("kids", fill_value=0) + result = df.unstack(["employed", "kids"], fill_value=0) + tm.assert_frame_equal(result, expected) From 68b247a5ec81e7ba6bc6180e84fd469a573e4ddf Mon Sep 17 00:00:00 2001 From: Tanmay Daripa Date: Thu, 9 Jan 2020 19:47:53 +0530 Subject: [PATCH 11/22] Update v0.25.3.rst --- doc/source/whatsnew/v0.25.3.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/source/whatsnew/v0.25.3.rst b/doc/source/whatsnew/v0.25.3.rst index 4d4a540584912..f73a3f956f42e 100644 --- a/doc/source/whatsnew/v0.25.3.rst +++ b/doc/source/whatsnew/v0.25.3.rst @@ -10,7 +10,6 @@ including other versions of pandas. Bug fixes ~~~~~~~~~ -- Bug in missing fill_na parameter to DataFrame.unstack() with list of levels (:issue:`30740`) Groupby/resample/rolling ^^^^^^^^^^^^^^^^^^^^^^^^ From b35fed963d7a17d128480f6af22d338d3e424238 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Thu, 9 Jan 2020 19:16:31 +0530 Subject: [PATCH 12/22] BUG: #30740 added gh to comment --- pandas/tests/frame/test_reshape.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/frame/test_reshape.py b/pandas/tests/frame/test_reshape.py index e8d52be8aa0aa..5bef8d70b6ca4 100644 --- a/pandas/tests/frame/test_reshape.py +++ b/pandas/tests/frame/test_reshape.py @@ -1132,7 +1132,7 @@ def test_stack_timezone_aware_values(): class TestMultiIndexReshape: def test_unstacking_multi_index_df(self): - # BUG: 30740 + # BUG: gh-30740 df = pd.DataFrame( { "name": ["Alice", "Bob"], From 7414e59a04eb611cfed6182d7fdc07d9bffd1c7c Mon Sep 17 00:00:00 2001 From: Tanmay Date: Thu, 9 Jan 2020 19:40:51 +0530 Subject: [PATCH 13/22] BUG #30740 moved bug doc to v1.0.0 --- doc/source/whatsnew/v1.0.0.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/source/whatsnew/v1.0.0.rst b/doc/source/whatsnew/v1.0.0.rst index 11a6f2628ac52..b172b385761c4 100755 --- a/doc/source/whatsnew/v1.0.0.rst +++ b/doc/source/whatsnew/v1.0.0.rst @@ -1039,6 +1039,7 @@ Reshaping - Dtypes are now preserved when transposing a ``DataFrame`` where each column is the same extension dtype (:issue:`30091`) - Bug in :func:`merge_asof` merging on a tz-aware ``left_index`` and ``right_on`` a tz-aware column (:issue:`29864`) - Improved error message and docstring in :func:`cut` and :func:`qcut` when `labels=True` (:issue:`13318`) +- Bug in missing fill_na parameter to DataFrame.unstack() with list of levels (:issue:`30740`) Sparse ^^^^^^ From 1d164ce635a0eef32d53deced1302ef41840a778 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Thu, 9 Jan 2020 19:45:00 +0530 Subject: [PATCH 14/22] BUG: #30740 removed class for tests --- pandas/tests/frame/test_reshape.py | 33 +++++++++++++++--------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/pandas/tests/frame/test_reshape.py b/pandas/tests/frame/test_reshape.py index 5bef8d70b6ca4..e5b75f95081b9 100644 --- a/pandas/tests/frame/test_reshape.py +++ b/pandas/tests/frame/test_reshape.py @@ -1130,20 +1130,19 @@ def test_stack_timezone_aware_values(): tm.assert_series_equal(result, expected) -class TestMultiIndexReshape: - def test_unstacking_multi_index_df(self): - # BUG: gh-30740 - df = pd.DataFrame( - { - "name": ["Alice", "Bob"], - "score": [9.5, 8], - "employed": [False, True], - "kids": [0, 0], - "gender": ["female", "male"], - } - ) - df = df.set_index(["name", "employed", "kids", "gender"]) - df = df.unstack(["gender"], fill_value=0) - expected = df.unstack("employed", fill_value=0).unstack("kids", fill_value=0) - result = df.unstack(["employed", "kids"], fill_value=0) - tm.assert_frame_equal(result, expected) +def test_unstacking_multi_index_df(self): + # BUG: gh-30740 + df = pd.DataFrame( + { + "name": ["Alice", "Bob"], + "score": [9.5, 8], + "employed": [False, True], + "kids": [0, 0], + "gender": ["female", "male"], + } + ) + df = df.set_index(["name", "employed", "kids", "gender"]) + df = df.unstack(["gender"], fill_value=0) + expected = df.unstack("employed", fill_value=0).unstack("kids", fill_value=0) + result = df.unstack(["employed", "kids"], fill_value=0) + tm.assert_frame_equal(result, expected) From 591c74751b802908b47ebd194710f4cc28515e14 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Thu, 9 Jan 2020 19:28:56 +0530 Subject: [PATCH 15/22] BUG #30740 moved to test/frames/test_reshape.py --- pandas/tests/reshape/test_reshape.py | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/pandas/tests/reshape/test_reshape.py b/pandas/tests/reshape/test_reshape.py index a2bce064aff88..f25291f4aef12 100644 --- a/pandas/tests/reshape/test_reshape.py +++ b/pandas/tests/reshape/test_reshape.py @@ -645,22 +645,3 @@ def test_reshaping_multi_index_categorical(self): index=dti.rename("major"), ) tm.assert_frame_equal(result, expected) - - -class TestMultiIndexReshape: - def test_unstacking_multi_index_df(self): - # see gh-30740 - df = pd.DataFrame( - { - "name": ["Alice", "Bob"], - "score": [9.5, 8], - "employed": [False, True], - "kids": [0, 0], - "gender": ["female", "male"], - } - ) - df = df.set_index(["name", "employed", "kids", "gender"]) - df = df.unstack(["gender"], fill_value=0) - expected = df.unstack("employed", fill_value=0).unstack("kids", fill_value=0) - result = df.unstack(["employed", "kids"], fill_value=0) - tm.assert_frame_equal(result, expected) From a1dbd08944e8219674a2ef7d9ba1fcbdc4b31b8a Mon Sep 17 00:00:00 2001 From: Tanmay Daripa Date: Thu, 9 Jan 2020 20:39:01 +0530 Subject: [PATCH 16/22] removed self from function --- pandas/tests/frame/test_reshape.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/frame/test_reshape.py b/pandas/tests/frame/test_reshape.py index e5b75f95081b9..63e756654c813 100644 --- a/pandas/tests/frame/test_reshape.py +++ b/pandas/tests/frame/test_reshape.py @@ -1130,7 +1130,7 @@ def test_stack_timezone_aware_values(): tm.assert_series_equal(result, expected) -def test_unstacking_multi_index_df(self): +def test_unstacking_multi_index_df(): # BUG: gh-30740 df = pd.DataFrame( { From c3c344755f3815548f40f664a2749f29d90bcb1a Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Thu, 9 Jan 2020 09:54:22 -0600 Subject: [PATCH 17/22] Update v1.0.0.rst --- doc/source/whatsnew/v1.0.0.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v1.0.0.rst b/doc/source/whatsnew/v1.0.0.rst index b172b385761c4..c60a6f4ebef33 100755 --- a/doc/source/whatsnew/v1.0.0.rst +++ b/doc/source/whatsnew/v1.0.0.rst @@ -1039,7 +1039,7 @@ Reshaping - Dtypes are now preserved when transposing a ``DataFrame`` where each column is the same extension dtype (:issue:`30091`) - Bug in :func:`merge_asof` merging on a tz-aware ``left_index`` and ``right_on`` a tz-aware column (:issue:`29864`) - Improved error message and docstring in :func:`cut` and :func:`qcut` when `labels=True` (:issue:`13318`) -- Bug in missing fill_na parameter to DataFrame.unstack() with list of levels (:issue:`30740`) +- Bug in missing `fill_na` parameter to :meth:`DataFrame.unstack` with list of levels (:issue:`30740`) Sparse ^^^^^^ From c93cbc8d61fe51aaa9b113830a1386156c4a0145 Mon Sep 17 00:00:00 2001 From: Tanmay Daripa Date: Thu, 9 Jan 2020 23:26:53 +0530 Subject: [PATCH 18/22] changed expected to fixed datframe in test --- pandas/tests/frame/test_reshape.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/pandas/tests/frame/test_reshape.py b/pandas/tests/frame/test_reshape.py index 63e756654c813..31eff0c7fac7b 100644 --- a/pandas/tests/frame/test_reshape.py +++ b/pandas/tests/frame/test_reshape.py @@ -1132,7 +1132,7 @@ def test_stack_timezone_aware_values(): def test_unstacking_multi_index_df(): # BUG: gh-30740 - df = pd.DataFrame( + df = DataFrame( { "name": ["Alice", "Bob"], "score": [9.5, 8], @@ -1145,4 +1145,17 @@ def test_unstacking_multi_index_df(): df = df.unstack(["gender"], fill_value=0) expected = df.unstack("employed", fill_value=0).unstack("kids", fill_value=0) result = df.unstack(["employed", "kids"], fill_value=0) + expected = DataFrame( + [[9.5, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 8.0]], + Index(["Alice", "Bob"], name="name"), + columns= MultiIndex.from_tuples( + [ + ("score", "female", False, 0), + ("score", "female", True, 0), + ("score", "male", False, 0), + ("score", "male", True, 0), + ], + names=[None, "gender", "employed", "kids"], + ), + ) tm.assert_frame_equal(result, expected) From 6cc15ef3bc77941f2340fb1cb386195dc2859c46 Mon Sep 17 00:00:00 2001 From: Tanmay Daripa Date: Thu, 9 Jan 2020 23:38:37 +0530 Subject: [PATCH 19/22] Update pandas/tests/frame/test_reshape.py Co-Authored-By: Simon Hawkins --- pandas/tests/frame/test_reshape.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/frame/test_reshape.py b/pandas/tests/frame/test_reshape.py index 31eff0c7fac7b..26e32e3ffc560 100644 --- a/pandas/tests/frame/test_reshape.py +++ b/pandas/tests/frame/test_reshape.py @@ -1148,7 +1148,7 @@ def test_unstacking_multi_index_df(): expected = DataFrame( [[9.5, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 8.0]], Index(["Alice", "Bob"], name="name"), - columns= MultiIndex.from_tuples( + columns=MultiIndex.from_tuples( [ ("score", "female", False, 0), ("score", "female", True, 0), From d2249e0bbab7b4e7ba807828c9402786026c1daa Mon Sep 17 00:00:00 2001 From: Tanmay Daripa Date: Thu, 9 Jan 2020 23:38:45 +0530 Subject: [PATCH 20/22] Update pandas/tests/frame/test_reshape.py Co-Authored-By: Simon Hawkins --- pandas/tests/frame/test_reshape.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/frame/test_reshape.py b/pandas/tests/frame/test_reshape.py index 26e32e3ffc560..e4daf9a671fa6 100644 --- a/pandas/tests/frame/test_reshape.py +++ b/pandas/tests/frame/test_reshape.py @@ -1147,7 +1147,7 @@ def test_unstacking_multi_index_df(): result = df.unstack(["employed", "kids"], fill_value=0) expected = DataFrame( [[9.5, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 8.0]], - Index(["Alice", "Bob"], name="name"), + index=Index(["Alice", "Bob"], name="name"), columns=MultiIndex.from_tuples( [ ("score", "female", False, 0), From 6f750251575493d6d6c0487f4196dcddfa09477d Mon Sep 17 00:00:00 2001 From: Tanmay Daripa Date: Thu, 9 Jan 2020 23:38:53 +0530 Subject: [PATCH 21/22] Update pandas/core/reshape/reshape.py Co-Authored-By: Simon Hawkins --- pandas/core/reshape/reshape.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/reshape/reshape.py b/pandas/core/reshape/reshape.py index d04cad83cbbc3..97f416e32d07b 100644 --- a/pandas/core/reshape/reshape.py +++ b/pandas/core/reshape/reshape.py @@ -358,7 +358,7 @@ def _unstack_multiple(data, clocs, fill_value=None): result = data for i in range(len(clocs)): val = clocs[i] - result = result.unstack(val, fill_value) + result = result.unstack(val, fill_value=fill_value) clocs = [v if i > v else v - 1 for v in clocs] return result From 2809c5518564a5b4987455be31ae6ae6674629dc Mon Sep 17 00:00:00 2001 From: Tanmay Daripa Date: Thu, 9 Jan 2020 23:39:34 +0530 Subject: [PATCH 22/22] Update pandas/tests/frame/test_reshape.py Co-Authored-By: Simon Hawkins --- pandas/tests/frame/test_reshape.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/frame/test_reshape.py b/pandas/tests/frame/test_reshape.py index e4daf9a671fa6..56a0c8cf4f5bd 100644 --- a/pandas/tests/frame/test_reshape.py +++ b/pandas/tests/frame/test_reshape.py @@ -1131,7 +1131,7 @@ def test_stack_timezone_aware_values(): def test_unstacking_multi_index_df(): - # BUG: gh-30740 + # see gh-30740 df = DataFrame( { "name": ["Alice", "Bob"],