I have panel data for some time periods of several municipalities, I also have data of the amount of individuals in 20 income groups and the median income of each income group. I would like to calculate the gini coefficient of each municipality in each time period using this data. Any tips on how I can do this in a neat way?

Thanks!