I have a DataFrame df with some country statistics for years from 2014 to 2018. Some of the countries have values for each of the years, while some countries are missing some. The DataFrame looks like this:
countryName 2014 2015 2016 2017 2018
Afghanistan .. .. 281 .. ..
Albania .. .. .. 891 901
Algeria 791 801 804 817 820
...
I want to keep only the most recent data value, so for the DataFrame above, the result should be:
countryName value
Afghanistan 281 # the most recent value from 2016
Albania 901 # the most recent value from 2018
Algeria 820 # the most recent value from 2018
...