Python Practice › Pandas Programs › Program 39
Sum of a column
Write a pandas program to sum the age column.
Output
119
Approach
df["age"].sum().
Solution
import pandas as pddf = pd.DataFrame({"name": ["Alex", "John", "Peter", "Klaus"], "age": [30, 27, 29, 33]})print(df["age"].sum())Output
119
Learn the concept
New to this topic? Read the lesson, then come back.