Introduction to Pandas
Reviewed & published by Brayan K
Pandas is an open-source Python library for working with tabular data — the rows and columns you see in a spreadsheet — giving you fast, expressive tools to load, clean, analyse, and save real-world datasets.
Part of the free Pandas course at LearnCodingFast — hands-on lessons with examples you run in your browser, plus practice exercises and a quick quiz.
In this first lesson you'll learn what Pandas is, why analysts everywhere rely on it, how to install and import it, and you'll build your very first table of data.
What You'll Learn in This Lesson
- What Pandas is and the problems it solves
- Why Pandas is built on top of NumPy
- How to install Pandas with pip
- The standard import: import pandas as pd
- Build your first DataFrame from a dictionary
- Check your version with pd.__version__
1 What Is Pandas?
Pandas is a Python library for working with tabular data — data organised in rows and columns, exactly like a spreadsheet or a database table.
📊 Pandas gives you two core objects:
- A Series — a single labelled column of data (1-dimensional)
- A DataFrame — a full table of rows and columns (2-dimensional)
Pandas is built directly on top of NumPy, Python's fast numerical computing library. That means your data is stored in efficient C-backed arrays under the hood, so operations on millions of rows stay quick.
2 Why Use Pandas?
Plain Python lists and dictionaries struggle with real datasets. Pandas was designed to make data work effortless:
- Read any file — CSV, Excel, JSON, SQL, and more in a single line
- Clean messy data — handle missing values, duplicates, and bad types
- Filter and select — grab exactly the rows and columns you need
- Group and summarise — compute totals, averages, and counts by category
- Fast — vectorised operations powered by NumPy, no slow Python loops
3 Installing and Importing Pandas
Install Pandas once from your terminal or command prompt using pip, Python's package installer:
pip install pandasThis also installs NumPy automatically, because Pandas depends on it. If you use Anaconda, Pandas is already included.
Inside your Python file or notebook, import it with the universal alias pd:
import pandas as pdimport pandas as pd
# Check that Pandas is installed and see its version
print("Pandas version:", pd.__version__)
# Output (your version number may differ):
# Pandas version: 2.2.2
# ✅ Expected output:
# Pandas version: 2.3.34 Your First DataFrame
The fastest way to create a table is from a dictionary. Each key becomes a column name, and each list of values becomes that column's data.
Pandas automatically adds a numbered index (0, 1, 2, ...) down the left side to label each row.
import pandas as pd
# Each key is a column; each list is that column's values
data = {
"name": ["Alice", "Bob", "Carol"],
"age": [25, 30, 35],
"city": ["London", "Paris", "Berlin"],
}
df = pd.DataFrame(data)
print(df)
# Output:
# name age city
# 0 Alice 25 London
# 1 Bob 30 Paris
# 2 Carol 35 Berlin
# ✅ Expected output:
# name age city
# 0 Alice 25 London
# 1 Bob 30 Paris
# 2 Carol 35 Berlinimport pandas as pd
# 🎯 YOUR TURN: replace each ___ to build a table of 3 products
data = {
"product": ["Pen", "Notebook", "Eraser"],
"price": [___, ___, ___], # use the numbers 2, 5, and 1
}
df = pd.DataFrame(data)
print(df)
# Expected output:
# product price
# 0 Pen 2
# 1 Notebook 5
# 2 Eraser 1📋 Quick Reference
| Task | Code |
|---|---|
| Install Pandas | pip install pandas |
| Import Pandas | import pandas as pd |
| Check version | pd.__version__ |
| Create a table | pd.DataFrame(data) |
🎯 Mini Challenge: Your Movie List
Build a small DataFrame describing three of your favourite movies:
- Import Pandas as pd
- Create a dictionary with columns title, year, and rating
- Turn it into a DataFrame and print it
import pandas as pd
# 🎯 Build your own movie table — change these to real movies!
movies = {
"title": ["Inception", "Coco", "Up"],
"year": [2010, 2017, 2009],
"rating": [8.8, 8.4, 8.3],
}
df = pd.DataFrame(movies)
print(df)
# Output:
# title year rating
# 0 Inception 2010 8.8
# 1 Coco 2017 8.4
# 2 Up 2009 8.3
# ✅ Expected output:
# title year rating
# 0 Inception 2010 8.8
# 1 Coco 2017 8.4
# 2 Up 2009 8.3❓ Frequently Asked Questions
Lesson complete — welcome to Pandas!
You now know what Pandas is, why it's built on NumPy, how to install and import it, and you've created your first DataFrame from a dictionary.
Practice quiz
What is Pandas primarily used for?
- 3D game rendering
- Working with tabular data in rows and columns
- Sending HTTP requests
- Compiling C code
Answer: Working with tabular data in rows and columns. Pandas is a Python library for tabular data, like a spreadsheet of rows and columns.
Which library is Pandas built on top of for fast numerical computing?
- NumPy
- Matplotlib
- Django
- TensorFlow
Answer: NumPy. Pandas stores data in efficient C-backed NumPy arrays under the hood.
What is the standard import statement for Pandas?
- import pd as pandas
- from pandas import *
- import pandas as pd
- require('pandas')
Answer: import pandas as pd. The universal convention is import pandas as pd.
Which command installs Pandas?
- npm install pandas
- pip install pandas
- apt get pandas
- pandas --setup
Answer: pip install pandas. pip install pandas installs it (and NumPy automatically).
Which Pandas object is a single labelled column (1-dimensional)?
- A Panel
- A DataFrame
- A Matrix
- A Series
Answer: A Series. A Series is the 1-D building block; a DataFrame is the 2-D table.
When you build a DataFrame from a dictionary, what does each key become?
- A column name
- A row label
- A data type
- An index number
Answer: A column name. Each dictionary key becomes a column name and its list becomes the column's values.
When you build a DataFrame from a dictionary, what index does Pandas add by default?
- The first column's values
- Random unique IDs
- A numbered index 0, 1, 2, ...
- No index at all
Answer: A numbered index 0, 1, 2, .... Pandas adds an automatic RangeIndex (0, 1, 2, ...) down the left side.
How do you check the installed Pandas version?
- pd.show_version
- pd.__version__
- pandas.check()
- pd.info
Answer: pd.__version__. pd.__version__ prints the installed version string.
Where does the name 'Pandas' come from?
- The animal
- Python Data Analysis
- Panel data
- Parallel data
Answer: Panel data. It comes from 'panel data', an econometrics term for multi-dimensional datasets.
What is the shape of pd.DataFrame({'name': ['A','B','C'], 'age': [1,2,3]})?
- (2, 3)
- (6, 1)
- (1, 6)
- (3, 2)
Answer: (3, 2). Three rows and two columns gives a shape of (3, 2).
Continue this course
- Next: The Series: Pandas' 1-D Building Block — Create and work with a Series — a labelled one-dimensional array
- Quick reference: Pandas cheat sheet › Creating & Loading
Frequently asked questions
What is Pandas in Python?
Pandas is an open-source Python library for working with tabular data — rows and columns, like a spreadsheet. It provides two core objects, the Series (1-D) and the DataFrame (2-D), plus fast tools for loading, cleaning, analysing, and saving data.
How do I install Pandas?
Run pip install pandas in your terminal. Pandas depends on NumPy, which pip installs automatically. If you use Anaconda, Pandas comes pre-installed.
Why is Pandas so popular for data analysis?
It is built on top of NumPy for speed, reads almost any file format (CSV, Excel, JSON, SQL), and offers concise, expressive methods for filtering, grouping, and summarising data — tasks that would take many lines of plain Python.
What is the difference between Pandas and Excel?
Excel is a visual spreadsheet app; Pandas is code. Pandas handles far larger datasets, is fully reproducible, automatable, and integrates with the wider Python data ecosystem (NumPy, Matplotlib, scikit-learn).