I have the dataframe that looks like (real frame has years from 1990 to 2020):
| Year | Chains_Normalize | Alliance_Name |
|---|---|---|
| 1990 | 0.000 | Gaint Inc |
| 1990 | 0.000 | Kell Inc |
| 1990 | 0.000 | New Corp |
| 1991 | 13.222 | Sad Corp |
| 1991 | 18.152 | Second Corp |
| 1991 | 16.333 | Shin Inc |
| 1992 | 19.212 | No inc |
| 1992 | 0.000 | Third inc |
| 1992 | 14.332 | Fourth inc |
I have to calculate the percentage of alliances in every year if Chains_Normalize is not 0. (The idea is to count what percentage of all alliances from dataframe includes every year)
The result will look like this:
Year Percentage
1990 0.000
1991 33.333
1992 22.222
1990 has all zero alliances and it's percentage is 0.
1991 has 3 no-zero alliances and (3/9)*100 = 33.333
1992 has 2 no-zero alliances and (2/9)*100 = 22.222