how to remove last few rows in pandas dataframe code example Example: how to remove last 2 rows in a dataframe df1 = df.iloc[:3]