← Back to Pandas Course | Chapter 2: Series | Lesson 5 of 7

Series methods (head/tail/describe)

Quick methods let you peek at the start, end and summary of a Series.
Syntax
python
s.head(n)
s.tail(n)
s.describe()

Series methods (head/tail/describe)

head(n) shows the first n items and tail(n) the last n; both default to 5. describe() summarizes count, mean, std, min, quartiles and max for numbers. value_counts() tallies each distinct value.

Note: describe() on text data reports count, unique, top and freq.

Example: Series methods (head/tail/describe)

python
import pandas as pd

s = pd.Series([4, 8, 15, 16, 23, 42])
print(s.head(2))
print(s.tail(2))
print(s.describe())

# Output:
# 0    4
# 1    8
# dtype: int64
# 4    23
# 5    42
# dtype: int64
# count     6.000000
# mean     18.000000
# std      13.490738
# min       4.000000
# 25%       9.750000
# 50%      15.500000
# 75%      21.250000
# max      42.000000
# dtype: float64
Related Topics
Common Mistakes
  1. Forgetting head defaults to 5
  2. Using describe on very mixed data
  3. Confusing value_counts with unique
Chapter Summary
  • head and tail peek at the ends
  • describe summarizes
  • value_counts tallies values
  • Defaults are 5 rows
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.