Skip to content
Edition NigeriaGlobal
Country

You are in the Nigeria edition. Type your country to switch.

Set up your profile

Data skills: SQL and Python basics · Lesson 6 of 7

pandas basics and a first chart

pandas is a Python library that handles whole tables at once. This lesson reads the example sales file, looks at it, filters rows, groups and totals by city, draws a bar chart and saves it, and shows that every answer matches the SQL lessons.

Beginner9 min read6 steps

This lesson is complete in writing. A video for it is on its way.

What you will learn

  • By the end you can load a CSV file into pandas and take a first look at it.
  • You can add a calculated column and filter rows with a condition.
  • You can total values by group with groupby and join two tables with merge.
  • You can draw a bar or line chart, save it, and check that every figure matches SQL.

Key terms in this lesson

pandas
A free, open-source Python library for working with tables of data, used to read files, filter rows, group and total values, join tables and draw simple charts.
DataFrame
A table of data in Python's pandas library, with named columns that can each hold a different type, such as dates, text or numbers.
Code notebook
A document that mixes runnable code cells with their results, tables, charts and notes, so an analysis can be run step by step and read by others.
CSV file
Comma-separated values: a plain-text file in which each line is a row and commas separate the columns. The most common format for exchanging tables of data.
Data type
What kind of value a column holds, such as a whole number, a decimal, text or a date. Numbers stored as text cannot be added or averaged.
Boolean mask
A column of true and false values, one per row, built from a condition and used to keep only the rows where the condition is true.

Step 1 of 6

Loading a file and looking at it

Opening this step…

Step 2 of 6

Columns and a calculated column

This step opens when you finish the one above.

Step 3 of 6

Filtering rows

This step opens when you finish the one above.

Step 4 of 6

Grouping and joining

This step opens when you finish the one above.

Step 5 of 6

A first chart, saved as an image

This step opens when you finish the one above.

Step 6 of 6

Two tools, one answer

This step opens when you finish the one above.

Key takeaways

The key takeaways open when you finish every step.

Lesson quiz

6 questions. You need 85% to pass.

The quiz opens when you finish every step.

Stockertim Learn is education. It explains how investing works and never recommends buying or selling anything.

Up next

Skills for the AI ageAI as a coding partner: read, te…Read nowAI as a coding partner: read, test and fix its codeSkills for the AI age · Beginner · 15 minSkills for the AI ageSpreadsheet basics: cells, range…Read nowSpreadsheet basics: cells, ranges and formulasSkills for the AI age · Beginner · 15 minSkills for the AI ageIF, SUMIFS and COUNTIFSRead nowIF, SUMIFS and COUNTIFSSkills for the AI age · Beginner · 15 minSkills for the AI ageLookups: XLOOKUP, VLOOKUP and IN…Read nowLookups: XLOOKUP, VLOOKUP and INDEX MATCHSkills for the AI age · Beginner · 15 minFinancial data & analyticsLab 1: reading CSV files in Pyth…Read nowLab 1: reading CSV files in Python and SQLFinancial data & analytics · Advanced · 15 minFinancial data & analyticsLab 3: plotting prices and returnsRead nowLab 3: plotting prices and returnsFinancial data & analytics · Advanced · 15 minFinancial data & analyticsCharts done right, and spotting …Read nowCharts done right, and spotting misleading chartsFinancial data & analytics · Intermediate · 15 minSkills for the AI agePython basics: variables, lists,…Read nowPython basics: variables, lists, loops and functionsSkills for the AI age · Beginner · 15 minSkills for the AI ageSQL basics: SELECT, WHERE and OR…Read nowSQL basics: SELECT, WHERE and ORDER BYSkills for the AI age · Beginner · 15 minSkills for the AI agedata is organised: tables, rows,…Read nowHow data is organised: tables, rows, columns and keysSkills for the AI age · Beginner · 15 minSkills for the AI agePivot tables, charts and a simpl…Read nowPivot tables, charts and a simple dashboardSkills for the AI age · Beginner · 15 minSkills for the AI ageJoining tables: SQL JOIN for beg…Read nowJoining tables: SQL JOIN for beginnersSkills for the AI age · Beginner · 15 min
English