Getting Started with Pandas: A Beginner’s Tutorial

Working with data is a part of many jobs today. You may have used Excel or Google Sheets to manage information. If so, there is a tool called Pandas that can help you do the same tasksâfaster, easier, and with more control.
Pandas is a Python library that helps you organise, clean, and analyse data. In this tutorial, you will learn what Pandas is, how to install it, and how to do a few basic tasks using it.
1. What You Need Before You Start
To use Pandas, you need Python installed on your computer. If you do not have it, you can install it by downloading Anaconda (a free software that includes Python and Pandas). Alternatively, you can learn how to install Python by reading our free notes.
You can also install Pandas using this command in your terminal or command prompt:
pip install pandas
2. What Is Pandas Used For?

Pandas helps you:
- Read data from Excel or CSV files
- Organise the data in tables (called DataFrames)
- Clean the data (remove missing or wrong values)
- Analyse the data (e.g. find averages or totals)
- Create simple charts (with other tools)
It is widely used in business, science, education, and research.
3. Your First Pandas Program
Letâs look at a simple example. Open a Python environment (like Jupyter Notebook or an online tool such as Google Colab).
đ Suppose you have this file called sales.csv with the following content:
name,product,amount
Alice,Shirt,30
Bob,Shoes,50
Alice,Shirt,25
David,Shoes,60
Carol,Hat,20
Now letâs write a simple Pandas program:
import pandas as pd # Import the pandas library
# Step 1: Read the file
data = pd.read_csv('sales.csv')
# Step 2: Look at the first few rows
print(data.head())
# Step 3: Find the average sales amount
average = data['amount'].mean()
print("Average amount:", average)
đ What does this do?
import pandas as pd
tells Python to load the Pandas library.pd.read_csv()
reads the CSV file and stores the data in a table.data.head()
shows the first five rows.data['amount'].mean()
calculates the average amount.
4. Other Useful Tasks

Here are a few more things you can do with Pandas:
â Filter data:
# Show only rows where the product is "Shirt"
shirts = data[data['product'] == 'Shirt']
print(shirts)
â Add a new column:
# Add a new column with a 10% discount
data['discounted_price'] = data['amount'] * 0.9
print(data)
â Group and summarise:
# Find total sales for each product
totals = data.groupby('product')['amount'].sum()
print(totals)
5. What Is a DataFrame?
In Pandas, your table of data is called a DataFrame. It looks like a spreadsheet but is used in code. You can:
- Look at specific rows and columns
- Rename columns
- Remove missing data
- Sort values
For example:
# Rename the 'amount' column to 'price'
data = data.rename(columns={'amount': 'price'})
# Sort by price
sorted_data = data.sort_values(by='price', ascending=False)
print(sorted_data)
6. Common File Types You Can Read

Pandas can read many types of data files:
- CSV:
pd.read_csv('file.csv')
- Excel:
pd.read_excel('file.xlsx')
- JSON:
pd.read_json('file.json')
- SQL databases (with extra setup)
You do not need to manually open these files; Pandas can read them directly into Python.
7. Final Words
Pandas is a powerful and easy-to-learn tool for working with data. If you often find yourself copying and pasting in Excel, or working with large amounts of data, Pandas can save you time and give you more control.
You only need to learn a few commands to start doing useful things. From there, you can explore more advanced features at your own pace.