I have the following DF:
z = pd.DataFrame({2016:[4.0,np.nan,6.0,7.0,np.nan],2017:[np.nan,0,5.0,0,np.nan],2018:[4.0,3,np.nan,3,1.0],2019:[2.0,np.nan,np.nan,np.nan,3.4],'ratio':''})
I need a column named 'ratio' to store the ratio between the first year (without nan values) and last year (without nan values) for each row.
For example, for first row it would be 2016/2019, for the second, 2017/2018, for the third, 2016/2017 and so on.
I couldn't figure out how to solve this....