Series methods (head/tail/describe)
Quick methods let you peek at the start, end and summary of a Series.
In this page:
Syntax
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)
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
- Forgetting head defaults to 5
- Using describe on very mixed data
- 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: