Open soluentre opened 4 months ago
result, rename_mapper = ... pivot_table() result = result[keeplist] result = result.rename(rename_dict)
note: when using the add_percentage para, it will return a tuple (df, rename_dict)
pivot_table(index=['country', 'var'], columns='us_nonus', subtotal={'country': 'Top', 'var': 'Bottom'}, add_percentage={'US':'column', 'Non-US': 'column'}, add_column_percentage=['US', 'Non-US'])
refer to comments below