Compute Column Average with Pandas
Easy
You are given a list of dictionaries representing rows of data, e.g. [{"name": "Alice", "score": 80}, {"name": "Bob", "score": 90}]. Write a function average_score(data) that builds a Pandas DataFrame from this data and returns the average of the "score" column.
Input
A list of dicts, each with "name" and "score" keys.
Output
A float representing the average score.
Example
Input
[{"name": "Alice", "score": 80}, {"name": "Bob", "score": 90}, {"name": "Carl", "score": 70}]
Output
80.0
Use pd.DataFrame(data) to build the DataFrame, then df["score"].mean() to compute the average.
10 XP on solve
Back to lesson
Your Solution
Output
Click "Run" to execute your code...
⏳ Loading Python runtime (first run may take a few seconds)...
Log in to submit your solution and earn XP.