pandas dataframe get last row code example
Example 1: location of last row dataframe
rows = df.iloc[-2:]
Example 2: print last n rows of dataframe
df1.tail(n)
Example 3: pandas show head and tail
#make 100 3d random numbers
df = pd.DataFrame(np.random.randn(100,3))
# sort them by their axis sum
df = df.loc[df.sum(axis=1).index]
with pd.option_context('display.max_rows',10):
print(df)