Pandas — Series
Create Series
import pandas as pd
# From list
s = pd.Series([1, 2, 3, 4, 5])
print(s)
# With index
s = pd.Series([1, 2, 3], index=['a', 'b', 'c'])
print(s)
Operations
s = pd.Series([10, 20, 30, 40])
print(s + 5) # Add
print(s * 2) # Multiply
print(s.mean()) # Mean
print(s.sum()) # Sum
Indexing
s = pd.Series([10, 20, 30], index=['a', 'b', 'c'])
print(s['a']) # By label
print(s[0]) # By position
print(s[['a', 'c']]) # Multiple
Boolean indexing
s = pd.Series([1, 2, 3, 4, 5])
print(s[s > 3])
Mini Practice
- Create Series
- Perform operations
- Use indexing
- Apply boolean masks
Up Next
Continue with DataFrame - 2D labeled data structure.
Related Topics
Frequently Asked Questions about Series
What is Series in Pandas?
Series is a fundamental concept in Pandas. This lesson explains it step by step with clear examples, making it easy for beginners to understand.
How do I learn Series?
Start by reading the explanation above, then try the code examples. Practice by modifying the examples and experimenting with different values. Hands-on practice is the best way to learn Series.
Why is Series important in Pandas?
Series is essential for Pandas development. Understanding this concept will help you write better code and solve real-world problems more effectively.