Pandas Get Last Row/Index

February 25, 2021

Last Index

df.index[-1]

Last Row

df.iloc[[-1]]

or

df.tail(1)

Get column value in last row

df['rank'].iloc[-1]

or

df.iloc[-1, df.columns.get_loc('rank')]

or

df.loc[df.index[-1], 'rank']
This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.