So my data looks like:
Text version:
Month Stream Profit Users
0 2021-01 Google $50,000 8000
1 2021-01 Bing $5,000 2000
2 2021-02 Google $50,000 10000
3 2021-02 Bing $10,000 5000
4 2021-03 Google $50,000 15000
5 2021-03 Bing $25,000 10000
And I am trying to create merged column output with not only month-year merged but also totals of each value monthwise so I want my output to be visualized as something like:
And I am trying to visualize it in a jupyter notebook output. Data would be monthly level so it is possible to visualize it on a jupyter notebook and does not have to be written in an excel file. Because of high volume of data, I, of course, cannot go through each cell and merge in excel, and show anyways. It is also important to show totals next to individual contributions from a readability perspective so I cannot have a separate table grouped by months only and have total. Data is dynamic. There could be more than two streams or less for a particular month. There are 6 columns in actual data and I want to show percentages and totals for each so there will be 3x more numerical columns than the actual number of numerical columns in data. But the number of features is pretty much fixed. I am currently looking at pandas styling and have gone through questions like:
But they are group-by-based solutions which are not valid for my case as there could be some cases where the total is equal coincidently for two months and I do not want to combine them. Moreover, the position of totals is really important for me to be next to each percentage contribution so by groupby approach, I would be losing that as well. The solution does not have to be pandas styling based and I am open to any solution as long as it is capable to incorporate streams dynamically, take care of each column and their totals separately and display totals next to each individual column. It even does not have to be a tabular output either but any visualization that can carry similar information with readability would be good enough. Feel free to suggest any approach that I might have missed out on and would be a better way to approach this problem.