Python Practice › Pandas Programs › Program 42

Mean of a column

EasyPandas Programs · 42 of 95

Write a pandas program to find the mean age.

Advertisement
Output
29.75

Approach

  1. mean().

Solution

Python
import pandas as pddf = pd.DataFrame({"name": ["Alex", "John", "Peter", "Klaus"], "age": [30, 27, 29, 33]})print(df["age"].mean())
Output
29.75
Advertisement

Learn the concept

New to this topic? Read the lesson, then come back.

More pandas programs

← All 95 Pandas Programs