I have a dataframe that looks like the following:
s1 s2 s3 s4
0 v1 v2 v3 v4
0 v5 v6 v7 np.nan
0 v8 np.nan v9 np.nan
0 v10 np.nan np.nan np.nan
Essentially from top down there are numerical values and across columns at some random index values will switch to np.nan only.
I've used .apply(pd.Series.last_valid_index) to get the indexes for which the values are still numerical, however, I'm not sure of the most efficient way to retrieve a series for which I have the actual value at the last valid index.
Ideally I'd be able to derive a series that looks like:
value
s1 v10
s2 v6
s3 v9
s4 v4
or as a dataframe that looks like
s1 s2 s3 s4
0 v10 v6 v9 v4
Many thanks!