I’ve data like that:
data = {
'nomenclature': ['Display_product', 'Display_product', 'Decorative_textile', 'Decorative_textile', 'Children_clothing', 'Children_clothing', 'Children_textile', 'Children_textile', 'Home_textile', 'Home_textile'],
'city': [1, 2, 1, 2, 1, 2, 1, 2, 1, 2],
'sales_2022': [4249.83, 7676.52, 428591.60, 580723.77, 2384600.57, 1878142.39, 316407.44, 309485.86, 10419592.44, 9594930.55],
'sales_2023': [39376.59, 32938.23, 287329.79, 470398.06, 2663005.41, 2253031.33, 333918.23, 312715.71, 10963845.16, 9967580.97]
}
append is not working for me, I’m getting an error. I know I can create a new column for calculating the percentage, but what if I need to get 3 or 4 pivot tables from 1? Want to automize that.
Maybe there is some library close to pivot tables in Excel that can sum a column, add a subtotal, calculate % and display the total, sums and percentages (100, and not sum subtotals)?
Vladimir is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.