how to remove the last two lines of a dataframe in python code example Example: how to remove last 2 rows in a dataframe df1 = df.iloc[:3]