Three Facts, No Loops

Data with PythonEasy+10 XP+10

Three Facts, No Loops

A café keeps its orders as a list of dictionaries. Every dictionary has the same keys, such as item, price and cups.

The manager wants three quick facts about the orders.

Task: write quick_summary(records, column) that turns records into a DataFrame and returns a list of three things:

  1. the number of rows
  2. the number of columns
  3. the average of the column named column, rounded to 2 decimal places

records always has at least one dictionary, and column always holds numbers.

Examples

records = [{"item": "latte", "price": 3.2, "cups": 2}, {"item": "tea", "price": 2.1, "cups": 1}, {"item": "mocha", "price": 3.6, "cups": 3}]
column = "price"
returns [3, 3, 2.97]
records = [{"item": "latte", "price": 3.2, "cups": 2}, {"item": "tea", "price": 2.1, "cups": 1}, {"item": "mocha", "price": 3.6, "cups": 3}]
column = "cups"
returns [3, 3, 2.0]

Hints

Solve it to unlock the solution

Once your code passes every test, a reference solution shows up here so you can compare it with yours.

solution.py
CtrlEnterto run