👋 Introduction
Have you ever used Excel to create tables and analyze data? What if we told you Python can do all of that — and more — using a library called Pandas? 📊🐼
Pandas is like a super-smart assistant that helps Python handle data easily. It's perfect for students who want to play with numbers, lists, tables, and real-world data like marksheets, cricket scores, or class attendance.
🧠 What is Pandas?
Pandas is a Python library that helps you store, analyze, and manipulate data just like Excel but with code!
🧪 Fun Fact:
The name Pandas comes from "Panel Data," a term used in statistics.
✅ Why Should School Students Learn Pandas?
-
Helps you work with tables of data easily
-
Perfect for Science projects, maths stats, or IT assignments
-
Gives you a real-world skill used in data science and AI!
🛠️ How to Install Pandas?
Before using Pandas, install it by running:
📦 Importing Pandas in Your Code
Here, pd
is just a nickname we use for Pandas to make writing code faster.
📋 Pandas Data Structures
Pandas has two main data structures:
-
Series – Like a single column (like a list with labels)
-
DataFrame – Like an Excel sheet (table with rows and columns)
🔢 1. Pandas Series
A Series is like a list, but each item has a label (called an index).
✨ Example:
🖨️ Output:
📊 2. Pandas DataFrame
A DataFrame is like a table. It's the most used tool in Pandas.
✨ Example:
🖨️ Output:
🔍 Exploring the DataFrame
✅ View first few rows:
✅ Get column names:
✅ Get statistics:
🎯 Real-Life Example – Class Marks
Let’s create a student marksheet!
✏️ Editing the Data
➕ Add a new column:
➖ Remove a column:
📁 Reading from a CSV File
If your data is stored in a file like students.csv
, you can read it like this:
💾 Writing Data to a File
You can also save your data to a file:
🧪 Try it Yourself – Challenge Time! 🎯
-
Create a DataFrame for your daily study schedule (Subjects, Time in minutes)
-
Calculate the total study time in a day
-
Save it in a CSV file