Skip to content

Commit c23675a

Browse files
committed
fix incorrect usage in pivot
1 parent 93efbc6 commit c23675a

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

pandas/core/reshape/pivot.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -99,19 +99,15 @@ def pivot_table(data, values=None, index=None, columns=None, aggfunc='mean',
9999

100100
if not dropna:
101101
from pandas import MultiIndex
102-
try:
102+
if table.index.nlevels > 1:
103103
m = MultiIndex.from_arrays(cartesian_product(table.index.levels),
104104
names=table.index.names)
105105
table = table.reindex(m, axis=0)
106-
except AttributeError:
107-
pass # it's a single level
108106

109-
try:
107+
if table.columns.nlevels > 1:
110108
m = MultiIndex.from_arrays(cartesian_product(table.columns.levels),
111109
names=table.columns.names)
112110
table = table.reindex(m, axis=1)
113-
except AttributeError:
114-
pass # it's a single level or a series
115111

116112
if isinstance(table, ABCDataFrame):
117113
table = table.sort_index(axis=1)

0 commit comments

Comments
 (0)