Python Practice › Pandas Programs › Program 65

Remove the first n rows

EasyPandas Programs · 65 of 95

Write a pandas program to remove the first n rows.

Advertisement
Output
    name  age
2  Peter   29
3  Klaus   33

Approach

  1. iloc[n:].

Solution

Python
import pandas as pddf = pd.DataFrame({"name": ["Alex", "John", "Peter", "Klaus"], "age": [30, 27, 29, 33]})print(df.iloc[2:])
Output
    name  age
2  Peter   29
3  Klaus   33

Learn the concept

New to this topic? Read the lesson, then come back.

More pandas programs

← All 95 Pandas Programs

Leave a Comment