Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons

© 2026 BraveProgrammer. All rights reserved.

  1. Courses
  2. /
  3. Master Data Science with Python

Lesson 18 of 60 · python

DataFrames: Tabular Data in Pandas

Duration: 20 minutes

DataFrames Basics

A DataFrame is a 2‑dimensional labeled data structure with columns of potentially different types.

Creating DataFrames

import pandas as pd

# From a dict of lists
df = pd.DataFrame({
    "city": ["NY", "LA", "SF"],
    "population": [8.4, 4.0, 0.9],
    "area": [783, 1214, 600]
})
print(df)

Inspecting DataFrames

print(df.head())    # first 5 rows
print(df.info())    # summary
print(df.describe())   # numeric stats

Selecting columns

pop = df["population"]
print(pop)

Adding a new column

df["density"] = df["population"] / df["area"]
print(df)

Info

Missing values appear as NaN. Use .isna() to spot them.

Previous: Series: The One‑Dimensional Pandas ObjectNext: Reading Data: CSV, Excel, JSON, and More