Data & charts on Mac

Turn a table of numbers
into an answer.

Compare expenses, summarise a CSV or draw your first chart. The Mac app includes the Python libraries to help you get there.

Python code and NumPy results in the Mac app
Write your code. Run it. See the result. Mac App Store edition.

Start with the question

What do you want your data to tell you?

pandas

Find the useful rows.

Read a CSV, filter a column and group related records. For an expense list, you could total each category and see where the money goes.

NumPy

Calculate across a whole set.

Work with arrays of numbers rather than calculating one value at a time. Try an average, a range or a formula applied to every measurement.

Matplotlib

Make the pattern visible.

Turn your results into a chart. Compare categories with bars or use a line to follow change over time.

Try it yourself

Three expenses.
One useful summary.

Paste this example into a Python file on your Mac and run it. pandas groups the entries and adds up each category.

Then add a new row or change an amount. When you are comfortable with the result, try the same idea with a CSV of your own.

Illustrative example. Uses pandas, included with the Mac app.

expenses.py

import pandas as pd

expenses = pd.DataFrame({
    "category": ["Food", "Travel", "Food"],
    "amount": [12, 8, 18],
})

totals = expenses.groupby("category")["amount"].sum()
print(totals.to_string())
category
Food      30
Travel     8

Beyond spreadsheets

Give your next script something new to do.

Bring in data from an API

Use Requests to fetch a response from a web service. Read its JSON and choose the fields your script needs.

Explore a web page

Use Beautiful Soup to inspect HTML and extract text or links from pages you are allowed to access.

Work with images

Use Pillow to open an image, read its dimensions or make a resized copy. Turn a repeatable image task into Python code.

pandasNumPyMatplotlibRequestsBeautiful SoupPillow

Keep the first version small

Answer one question. Then add the next.

  1. Start with a few records

    Use a small sample you can check by eye. It makes unexpected results easier to spot.

  2. Print before you plot

    Check the calculated values in the console. Make sure they answer the question you intended.

  3. Try your own data

    Replace the sample with a file you want to understand. Keep an original copy as you experiment.

Bring a question. Let Python help you answer it.

The data libraries are included in the Mac app.

Get the Mac app