How to Calculate Percentage Contributions Over Time in Python + R
One data science summarisation job that can be a littler trickier than we have discussed so far is to calculate the percentage contribution
In Python we will be using the .transform() method which allows us to aggregate the sum
To do the same job in R requires a different approach since we don't have an index or similar .transform() method. Instead we can use either a combination of a group by and summarise
Recommended by LinkedIn
Calculating percentage contributions over time is important for many applications in data science and can be used not only to investigate seasonal changes
Remember to like and subscribe to the Data Science Code in Python + R newsletter to get your weekly reminder and commit to learning a little more Python and/or R every week. Each newsletter covers how to do one data science job in both Python and R.