Skip to content

Pandas DataFrame Basics

Create, filter, and aggregate Pandas DataFrames with practical examples for real datasets.

A DataFrame is a 2D table with labeled rows and columns — think Excel, but programmable.

Creating a DataFrame

import pandas as pd

df = pd.DataFrame({
    "name": ["Ada", "Linus", "Guido"],
    "score": [95, 87, 91],
})
print(df.head())

Filtering and aggregating

top = df[df["score"] > 90]
mean_score = df["score"].mean()

Use df.info() and df.describe() early to understand column types and spot missing values before any analysis.

AdSense — in-article slot

Related Reading