To drop last n rows:
df.drop(df.tail(n).index,inplace=True) # drop last n rows
By the same vein, you can drop first n rows:
df.drop(df.head(n).index,inplace=True) # drop first n rows
More Related Contents:
- Extract the data and modify an existing excel with openpyxl
- cartesian product in pandas
- Keep other columns when doing groupby
- Convert the string 2.90K to 2900 or 5.2M to 5200000 in pandas dataframe
- What does `ValueError: cannot reindex from a duplicate axis` mean?
- Reconstruct a categorical variable from dummies in pandas
- Conditionally fill column values based on another columns value in pandas
- Remove duplicate rows from Pandas dataframe where only some columns have the same value
- Rename result columns from Pandas aggregation (“FutureWarning: using a dict with renaming is deprecated”)
- How to switch columns rows in a pandas dataframe
- Quickest way to make a get_dummies type dataframe from a column with a multiple of strings
- Using numpy.genfromtxt to read a csv file with strings containing commas
- Plot correlation matrix using pandas
- Insert a Pandas Dataframe into mongodb using PyMongo
- Pandas unstack problems: ValueError: Index contains duplicate entries, cannot reshape
- Copy pandas dataframe to excel using openpyxl
- Finding label location in a DataFrame Index
- Create new dataframe in pandas with dynamic names also add new column
- How to convert a dataframe to a dictionary
- Filling missing values using forward and backward fill in pandas dataframe (ffill and bfill)
- Truncate `TimeStamp` column to hour precision in pandas `DataFrame`
- Querying for NaN and other names in Pandas
- Efficiently select rows that match one of several values in Pandas DataFrame [duplicate]
- Pandas Dataframe to Excel Sheet
- pandas: slice a MultiIndex by range of secondary index
- Can Pandas read and modify a single Excel file worksheet (tab) without modifying the rest of the file?
- Pandas combining rows based on dates
- Collapsing rows in a Pandas dataframe if all rows have only one value in their columns
- Preserving column order in Python Pandas DataFrame
- Multi Index Sorting in Pandas