Catalogue · First steps in Python and SQL, with AI

Add a calculated column and a total

You add a calculated column, then get the total and the average.

JupyterLiteBeginner0:22Capsule 4 of 12
SkillKapsul

Space: play · ← →: 5 seconds · M: sound · F: full screen

The steps

The exact sequence, in order.

  1. 01

    Type df["amount"] = df["quantity"] * df["unit_price"].

  2. 02

    Type print(df["amount"].sum()): 14976.0.

  3. 03

    Type print(df["amount"].mean()): 48.0, the average basket.

  4. 04

    Note these two numbers: you’ll use them to check.

The habit to keep

Keep a known number to check the next calculations.

Related capsules

You might also like

Newsletter

Monday's capsule

One skill a week, straight to your inbox. The easiest way to keep learning without thinking about it.

No spam, no reselling. One-click unsubscribe.

Your data stays in the EU. Never sold.

SkillKapsul