Free Online Course · Self-paced · Hands-on

Pandas Tutorial for Data Analysis (with examples)

Free pandas tutorial for Python data analysis: read CSV files, select, clean, merge, group, pivot, and plot DataFrames with runnable examples you can copy.

  • 11 chapters
  • 38 lessons
  • ~8h
  • Beginner to Intermediate
  • Tested with Python 3.13.x
  • Updated Sep 2026
Pandas Tutorial for Data Analysis (with examples)
By Last updated

About this course

This free course teaches pandas in the order you use it on a real dataset: load a file, check what you have, select and clean the parts you need, combine it with other tables, then group, reshape, and plot the result. Each chapter covers one of those steps. When you need a parameter a lesson leaves out, the pandas documentation has the full reference.

Every lesson is a short script you can paste into Jupyter or IPython and run as it is, with the printed DataFrame shown underneath so you can compare your output line by line. The examples were written on pandas 2.x. pandas 3.0 changed how copies and string columns behave, and the FAQ covers what that means for code you copy from here.

If DataFrames are new to you, start with Pandas Concepts and then Selecting Rows and Columns, because every later lesson relies on loc and boolean filters. If you already use pandas, go straight to groupby, pivot, or resample.

What you'll learn

  • Explain how a Series, a DataFrame, and the index fit together
  • Read and write CSV files, print a full DataFrame, and export one to SQL
  • Check shape, size, row counts, and unique values before you change anything
  • Select rows and columns with loc, iloc, at, iat, and boolean filters
  • Add, rename, reorder, and drop columns and rows, and convert columns to int, float, and datetime
  • Drop missing values and set or reset the index
  • Combine DataFrames with concat and merge, then aggregate and reshape with groupby, pivot, and melt
  • Resample time series, calculate rolling windows, apply functions with map, and plot histograms

Who this course is for

  • Python developers who still loop over CSV rows by hand and want vectorized operations instead
  • Analysts moving from Excel or Google Sheets to notebooks they can rerun on next month's data
  • SQL users who want the same filter, join, and group-by work in memory from Python
  • Data engineers who clean and reshape extracts before loading them into a database or BI tool

Prerequisites

  • Basic Python, including variables, lists, dicts, functions, and list comprehensions
  • Python 3.11 or newer, which pandas 3.0 requires
  • pandas installed in a virtual environment with pip install pandas, plus matplotlib for plotting and SQLAlchemy with a database driver for the SQL export lesson
  • Jupyter Notebook, JupyterLab, or an IPython session to run the examples. No paid tools or cloud accounts are needed

Versions and testing environment

Every command in this course was run on this stack

ComponentVersionNotes
Python 3.13.x Recorded in the reset_index lesson. pandas 3.0 needs Python 3.11 or newer
pandas 2.2.x A few older lessons still show DataFrame.append(), which pandas 2.0 removed, and point you to pd.concat instead
Ubuntu — Lab OS for the recorded runs. The code itself runs the same on Windows and macOS
matplotlib — Needed only for the histogram lesson

Syllabus

11 chapters · 38 lessons · ~8h of reading

  1. 1 Pandas Concepts (start here if new) 2 lessons · ~27 min
    1. Part 1 Introduction to Python Pandas 11 min read
    2. Part 2 The Pandas DataFrame explained 16 min read
  2. 2 Reading and Writing Data 4 lessons · ~50 min
    1. Part 3 Read CSV files with pandas 13 min read
    2. Part 4 Write a DataFrame to CSV 14 min read
    3. Part 5 Export a DataFrame to SQL 10 min read
    4. Part 6 Print the entire DataFrame (no truncation) 13 min read
  3. 3 Inspecting and Sizing DataFrames 3 lessons · ~20 min
    1. Part 7 Count rows in a DataFrame 7 min read
    2. Part 8 Get the size and shape of a DataFrame 9 min read
    3. Part 9 Get unique values from a column 4 min read
  4. 4 Selecting Rows and Columns 5 lessons · ~43 min
    1. Part 10 loc vs iloc vs at vs iat - the difference 6 min read
    2. Part 11 Select by integer position with iloc 12 min read
    3. Part 12 Select a single column 7 min read
    4. Part 13 Select multiple columns 7 min read
    5. Part 14 Filter rows by column value 11 min read
  5. 5 Adding and Modifying Columns / Rows 5 lessons · ~42 min
    1. Part 15 Add a new column to a DataFrame 6 min read
    2. Part 16 Add an empty column 13 min read
    3. Part 17 Add a row to a DataFrame 7 min read
    4. Part 18 Rename one or more columns 16 min read
    5. Part 19 Change the order of columns Coming soon
  6. 6 Cleaning and Type Conversion 6 lessons · ~1h 2m
    1. Part 20 Convert a column to int 6 min read
    2. Part 21 Convert a column to float 13 min read
    3. Part 22 Convert strings to datetime 15 min read
    4. Part 23 Drop missing values with dropna() 14 min read
    5. Part 24 Drop rows by condition 9 min read
    6. Part 25 Drop columns from a DataFrame 5 min read
  7. 7 Indexing 2 lessons · ~16 min
    1. Part 26 Set a column as the index 9 min read
    2. Part 27 Reset the DataFrame index 7 min read
  8. 8 Combining DataFrames 3 lessons · ~37 min
    1. Part 28 Concatenate DataFrames with concat() 18 min read
    2. Part 29 merge vs concat vs append vs join 13 min read
    3. Part 30 Build a DataFrame from a list of dictionaries 6 min read
  9. 9 Aggregation and Reshaping 5 lessons · ~52 min
    1. Part 31 Group and aggregate with groupby() 16 min read
    2. Part 32 Pivot tables in pandas 15 min read
    3. Part 33 Reshape with melt() 4 min read
    4. Part 34 Resample time-series data 11 min read
    5. Part 35 Rolling window calculations 6 min read
  10. 10 Iteration and Mapping 2 lessons · ~13 min
    1. Part 36 Iterate over DataFrame rows 9 min read
    2. Part 37 Apply a function with Series.map() 4 min read
  11. 11 Visualization 1 lesson · ~6 min
    1. Part 38 Create histograms from a DataFrame 6 min read

Hands-on labs

6 guided builds you run yourself

  1. Load a CSV with custom headers, columns, and row limits

    Read a file with a chosen header row and index, rename columns on load, skip rows, and import only the columns you need.

  2. Clean a dataset with missing values

    Find the gaps in a DataFrame and drop rows or columns by how many values are missing and where.

  3. Summarize data with groupby

    Group rows by one or more keys, compute sums and means per group, and filter out groups that do not qualify.

  4. Reshape long data into a pivot table

    Turn a long table of records into a wide summary with one row per key and one column per category.

  5. Resample a time series

    Convert timestamped data to a new frequency and fill the gaps with NaN, forward fill, or backward fill.

  6. Export a DataFrame to a SQL database

    Open a database connection, map column types, and write a DataFrame to a SQL table.

Where to go after this course

  • pandas user guideThe official reference for the parameters these lessons skip, and for the pandas 3.0 migration notes.
  • SQL courseFilter and join in the database first, then pull a smaller result into pandas.
  • Python courseFill gaps in functions, classes, and virtual environments once your notebooks turn into scripts.

Frequently Asked Questions

Should I install pandas 2.x or pandas 3.0?

Install pandas 3.0 for new work. It was released on January 21, 2026, needs Python 3.11 or newer, and is the version the official documentation now describes. If you are upgrading an existing project, the pandas team recommends moving to pandas 2.3 first, because it prints deprecation warnings for many of the changes that break in 3.0. The pandas 3.0 release notes list every breaking change.

Why does chained assignment no longer change my DataFrame in pandas 3.0?

pandas 3.0 makes Copy-on-Write the only mode. Any subset you take, including a single column, behaves as a copy, so a line such as df["price"][df["qty"] > 10] = 0 updates a temporary object and leaves df alone. Write it as one assignment instead:

python
df.loc[df["qty"] > 10, "price"] = 0
Output

The upside is that SettingWithCopyWarning is gone, and you no longer need defensive .copy() calls to silence it.

What changed with string columns in pandas 3.0?

Text columns now get a dedicated str dtype instead of object, and missing values in them are NaN. Code that checks df["name"].dtype == object stops matching, and assigning a number into a string column raises an error instead of quietly mixing types. The official string migration guide shows how to update those checks.

Should I learn pandas or Polars?

Learn pandas first if you are starting out. Most Python data libraries, plotting tools, and tutorials accept a pandas DataFrame, and it is the most widely used DataFrame library in Python. Polars is multi-threaded and can optimize a whole query before running it, so it tends to be faster on large datasets. Once you know pandas, trying Polars on a slow pipeline is a reasonable next step.

When should I use SQL instead of pandas?

Use SQL when the data lives in a database and you only need part of it. Filtering and joining in the database means you move fewer rows into memory. Use pandas once the data is on your machine and you need to reshape it, clean it, plot it, or hand it to a Python library. Most analysis work uses both: a SQL query pulls the rows, and pandas does the rest.

Deepak Prasad

R&D Engineer

Founder of GoLinuxCloud with 15+ years of expertise in Linux, Python, Go, Laravel, DevOps, Kubernetes, Git, Shell scripting, OpenShift, AWS, Networking, and Security. With extensive experience, he excels across development, DevOps, networking, and security, delivering robust and efficient solutions for diverse projects.

  • Go (programming language)
  • Python (programming language)
  • DevOps
  • Computer Security
  • Cloud Computing
  • Kubernetes
  • Linux
  • Ansible (software)