๐ 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
No comments:
Post a Comment