# Part 3 - Country-Level Detail
# b. Which 5 countries saw the largest percent decrease in forest area from 1990 to 2016? What was the percent change to 2 decimal places for each?
# فلترة الجدول على عام 1990 وعام 2016
country_1990 = forestation[(forestation['year'] == 1990) & (forestation['country_name'] != 'World')]
country_2016 = forestation[(forestation['year'] == 2016) & (forestation['country_name'] != 'World')]
# merge country 1990 & country 2016
merged_countries= country_1990.merge(country_2016, on=["country_name"], how="left", suffixes=('_1990', '_2016'))
# create a new column (pfa_difference)
merged_countries['pfa_difference'] = round(((merged_countries['forest_area_sqkm_1990'] - merged_countries['forest_area_sqkm_2016'])/
merged_countries['forest_area_sqkm_1990'])*100,2)
# top 5 by the largest percent decrease in forest area
result = merged_countries.sort_values(by='pfa_difference', ascending=False).head(5)
print(result[['country_name', 'pfa_difference']])