Informatics Practices · Class 12 · Python Pandas · Series
PandasSeries⏱️ 5 min read
Peeking: head() & tail()
Real datasets can have thousands of rows — printing all of them is useless. head() and tail() let you glance at just the top or bottom few to check your data looks right.
1Peek at the top or the bottom
Drag n and switch between head() and tail() to see exactly which rows come back.
head() & tail()
Big Series are long. Peek at just the top or bottom few rows — drag n to see how many.
a10
b20
c30
d40
e50
f60
g70
h80
i90
j100
what you called
s.head()
returns
a, b, c, d, e
Call it with no number and you get 5 rows by default.
2How they work
- 🔼
s.head(n)— the first n rows. Default is 5. - 🔽
s.tail(n)— the last n rows. Default is 5.
head_tail.py
Tip
These don't change your Series — they just return a small copy to look at. Call them with no number for 5 rows, or pass any count you like.
Quick Check
What does s.tail() return by default?