What is a Pandas Series?
A Pandas Series is similar to a list or a column in Excel.
It consists of two parts:
-
Values
-
Index (labels)
Example:
Output:
Here, 0, 1, 2 are the index values.
How to Create a Pandas Series
1. From a List
2. From a Dictionary
3. With Custom Index
Operations You Can Perform on a Series
1. Accessing Elements
By Index:
By Label (custom index):
2. Slicing
3. Mathematical Operations
You can apply operations to the whole Series:
4. Checking Data Type
5. Changing Data Type
6. Handling Missing Values
7. Filtering
8. Sorting
Sort by values:
Sort by index:
9. Applying Functions (Map / Apply)
10. Unique Values & Counts
Mini Project: Student Marks Analyzer Using Pandas Series
Objective:
Analyze marks of students using Series operations.
Step 1: Create a Series of Marks
Step 2: Find Highest and Lowest Marks
Step 3: Find Average Marks
Step 4: Filter Students Who Scored Above 85
Step 5: Add Grace Marks (5 Extra Marks)
Step 6: Count How Many Students Scored Each Mark
Output Summary:
-
You can see top performers
-
Identify weak students
-
Add grace marks
-
Analyze data in a single line
This small project shows how powerful and simple Pandas Series can be for real-world tasks.
Conclusion
Pandas Series is a fundamental part of data analysis in Python. It helps you store, manipulate, and analyze one-dimensional data efficiently. Once you master Series, it becomes easier to understand DataFrames and perform advanced data analysis.
No comments:
Post a Comment