Skip to content

Commit cdd8dae

Browse files
author
Christoph Möhl
committed
modified crosstable normalization for multi index data
1 parent a972936 commit cdd8dae

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pandas/core/reshape/pivot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ def _normalize(table, normalize, margins, margins_name='All'):
546546
}
547547

548548
elif margins is True:
549-
549+
#skip margin rows and/or cols for normalization
550550
normalizers = {
551551
'all': lambda x: x / x.iloc[:-1,:-1].sum(axis=1).sum(axis=0),
552552
'columns': lambda x: x.div(x.iloc[:-1,:].sum()).iloc[:-1,:],
@@ -563,7 +563,7 @@ def _normalize(table, normalize, margins, margins_name='All'):
563563
except KeyError:
564564
raise ValueError("Not a valid normalize argument")
565565

566-
table=f(table)
566+
table = f(table)
567567
table = table.fillna(0)
568568

569569
return table

0 commit comments

Comments
 (0)