Python

Pandas for Absolute Beginners — Clean and Analyse Your First Dataset

By Wycliff Kimani3 min read
Pandas for Absolute Beginners — Clean and Analyse Your First Dataset

What is Pandas and Why Do You Need It?

Pandas is the most important Python library for anyone working with data. If you want to become a data analyst, data scientist, or just someone who can work with spreadsheets in Python — Pandas is non-negotiable.

Think of Pandas as Excel, but inside Python. You can load data from CSV files, clean messy columns, filter rows, group data, calculate statistics, and export results — all in a few lines of code.

Installing Pandas

If you haven't installed Pandas yet, open your terminal and run:

If you are using Google Colab or Jupyter Notebook, Pandas is already installed. Just import it.

Loading Your First Dataset

The most common way to load data in Pandas is from a CSV file. Here's how:

df is short for DataFrame — the main data structure in Pandas. Think of it as a table with rows and columns, exactly like a spreadsheet. df.head() shows you the first 5 rows. It's always the first thing you run when you load a new dataset.

Exploring Your Data

Before cleaning anything, you need to understand what you're working with. These are the four commands every data analyst runs first:

df.shape returns something like (1000, 8) — meaning 1000 rows and 8 columns. df.describe() gives you the min, max, mean, and standard deviation for every numeric column in one go.

Finding and Handling Missing Values

Real datasets are messy. Missing values are one of the most common problems you'll face. Here's how to find them:

This shows you how many missing values exist in each column. Once you know where they are, you have two main options:

Which one you choose depends on the situation. If only a few rows are missing, dropping them is fine. If a whole column has gaps, filling with a sensible default is usually better.

Filtering and Selecting Data

One of the most powerful things about Pandas is how easy it is to filter rows based on conditions:

Basic Analysis — GroupBy and Aggregation

GroupBy is where Pandas gets really powerful. It lets you group your data by a category and calculate statistics for each group:

This is the foundation of exploratory data analysis. Most business questions come down to "what is the average X per Y?" — and GroupBy answers that in one line.

Saving Your Results

index=False stops Pandas from writing the row numbers as a column in your output file. Always include it.

What to Learn Next

You've covered the core Pandas workflow — load, explore, clean, filter, analyse, save. This is what 80% of real data analysis looks like. The natural next steps are merging datasets, data visualisation with Matplotlib and Seaborn, pivot tables, and working with dates. If you want to work through any of these with real data and a tutor who explains every line — that's exactly what my 1-on-1 sessions are for.

Want Help Applying This?

Book a 1-on-1 session and we'll work through this topic together with your actual code and data.

Book a Session
← Back to all articles