Skip to learning content

DATA SCIENCE PYTHON PLAYGROUND

Data Foundations · A little practice goes a long way.

← Choose a deckTINY TABLES · REAL PYTHON · YOUR PACE
Deck 02

Wrangle / Preprocess

Start after Inspect. Protect the original, then clean, reshape and combine with a reason for every change.

01 / A safe working copy

02 / New columns & clean text

03 / Types, dates & missingness

W12Core
Concept sketch: numeric text → numbers; invalid → NaNtext"2.5""bad""4"number2.5NaN4numeric text → numbers; invalid → NaN

Convert numeric text

Turn numeric-looking strings into usable numbers.

8 min · 3 practices
WR2Review
Concept sketch: Create a numeric column; Clean text; Convert numeric textpricedoubled244836W07raw" TEA ""Latte "clean"tea""latte"W10W07 + W10 + W12

Bridge review · Sections 02 + 03

Revisit new columns (W07) and clean text (W10) from Section 02, then numeric conversion (W12) from Section 03.

12 min · 3 retrieval tasks
W13Core
Concept sketch: same labels, explicit category dtypeobjectABAcategoryABAsame labels, explicit category dtype

Convert data types

Choose a type that fits the values.

8 min · 3 practices
W14Core
Concept sketch: text → datetime; invalid → NaTtext2026-06-01not a datedatetime2026-06-01NaTtext → datetime; invalid → NaT

Parse dates

Convert date text and handle invalid dates visibly.

8 min · 3 practices
W15Core
Concept sketch: extract calendar fields from datesdate2026-06-012026-07-03yearmonthday20266Mon20267Friextract calendar fields from dates

Work with dates

Extract useful calendar features from parsed dates.

8 min · 3 practices
W16Core
Concept sketch: drop rows missing the required valuerowpriceA2BNaNC4rowpriceA2C4drop rows missing the required value

Drop missing rows

Exclude only rows missing a required field.

8 min · 3 practices
W17Core
Concept sketch: fill only the gap with median 3rowpriceA2BNaNC4rowpriceA2B3C4fill only the gap with median 3

Fill missing values

Choose and document an imputation rule.

8 min · 3 practices
W18Core
Concept sketch: remove extra copies, keep first rownamepriceA2B4A2namepriceA2B4remove extra copies, keep first row

Remove duplicates

Remove verified extra copies.

8 min · 3 practices
WR3Review
Concept sketch: Parse dates; Drop missing rows; Fill missing values; Remove duplicatestext2026-06-01not a datedatetime2026-06-01NaTW14rowpriceA2BNaNC4rowpriceA2C4W16W14 + W16 + W17 + W18

Review · Gaps and duplicates

Retrieve earlier skills on a fresh table.

12 min · 4 retrieval tasks

04 / Groups & reshaping

W19Core
Concept sketch: one row per group, multiple summariesgroupvalueA2A4B8groupmeannA32B81one row per group, multiple summaries

Group and aggregate

Create readable, named group summaries.

8 min · 3 practices
W20Go Further
Concept sketch: group means aligned to original rowsgroupvaluemeanA23A43B88group means aligned to original rows

Groupwise transformation

Add a group statistic beside each original row.

8 min · 3 practices
W21Go Further
Concept sketch: pivot_table: aggregate repeated pairsgrpcolvalAX2AX4AY8grpXYA38pivot_table: aggregate repeated pairs

Build a pivot table

Summarise a measurement across two category axes.

8 min · 3 practices
W22Core
Concept sketch: wide → long: preserve all four valuesidxyA24B35idvarvalAx2Bx3Ay4By5wide → long: preserve all four values

Wide → long

Turn measurement columns into variable/value rows.

8 min · 3 practices
W23Go Further
Concept sketch: long → wide: unique id/variable pairsidvarvalAx2Ay4Bx3idxyA24B3NaNlong → wide: unique id/variable pairs

Long → wide

Reshape unique identifier/measurement pairs.

8 min · 3 practices
W24Core
Concept sketch: left join: keep unmatched rows tookeyvalueA2B4keyvaltagA2yesB4NaNlookup: A → yesleft join: keep unmatched rows too

Combine tables by keys

Join a lookup table while checking the relationship.

8 min · 3 practices
WR4Review
Concept sketch: Group and aggregate; Groupwise transformation; Wide → long; Combine tables by keysgroupvalueA2A4B8groupmeannA32B81W19groupvaluemeanA23A43B88W20W19 + W20 + W22 + W24

Review · Reshape and connect

Retrieve earlier skills on a fresh table.

12 min · 4 retrieval tasks

05 / Combining & preparing

06 / A responsible finish