35  Module 1 Cheat Sheet

Key concepts, definitions, and code from Chapters 1–3

A quick-reference summary of the essential ideas from Module 1. Click any section heading to jump to the full coverage in the book.


What Is Data Wrangling?

Data wrangling is the process of cleaning, transforming, joining, and summarizing raw data to make it ready for analysis.

  • Real-world data is messy: missing values, inconsistent formats, multiple files
  • Data scientists spend 50–80% of their time preparing data — not modeling
  • Data wrangling is the work, not a detour before the work

Python for Data Science

Why Python?

Reason Details
Popularity One of the top languages in data science and ML
Ecosystem pandas, numpy, matplotlib, seaborn, scikit-learn
Readability Clean syntax that’s approachable for beginners
Versatility Used for analysis, web apps, automation, and large-scale systems

AI as a Learning Tool

AI tools (ChatGPT, Copilot, etc.) are assistants, not autopilots.

AI can help you… AI cannot…
Write boilerplate code Understand your data’s context
Debug error messages Know your business goals
Explain new syntax Guarantee correct results
Generate practice examples Replace critical thinking

Rule of thumb: Always understand what the code does before you use it.


Coding Environments

Environment What it is Best for
Google Colab Cloud-based notebook, no install needed Getting started quickly
Anaconda Local Python distribution with navigator Full local control, offline work
VS Code Lightweight code editor with extensions Professional development workflow

All three environments support Jupyter notebooks (.ipynb files).


Jupyter Notebooks

Two cell types:

  • Code cells — write and run Python; press Shift + Enter to execute
  • Markdown cells — write formatted text, headings, and notes

Common Markdown:

# Heading 1
## Heading 2
**bold**   *italic*   `inline code`

Python Data Types

Type Name Example
int Integer 42, -7, 0
float Decimal 3.14, -0.5, 2.0
str String "hello", 'world'
bool Boolean True, False

Useful functions:

type(42)          # int
type("hello")     # str
int("5")          # convert string → int: 5
float(3)          # convert int → float: 3.0
str(100)          # convert int → string: "100"
print("hi")       # display output

Strings can use single or double quotes — both are valid:

name = "Taylor"
greeting = 'Hello'
combined = greeting + ", " + name + "!"   # string concatenation

Variables

A variable stores a value under a name so you can reuse it.

# Assigning variables
price = 9.99
quantity = 3
total = price * quantity

# Variables can be reassigned
price = 12.50

Naming rules:

Rule Valid Invalid
Start with a letter or _ sales_2024, _temp 2sales, 123abc
Letters, digits, underscores only first_name first-name, first name
Case-sensitive scoreScore
No reserved words class, if, for, True

Use descriptive snake_case names: total_revenue not tr or TotalRevenue.


Comparison Operators

Comparison operators always return True or False.

Operator Meaning Example Result
== Equal to 5 == 5 True
!= Not equal to 5 != 3 True
< Less than 3 < 5 True
> Greater than 5 > 10 False
<= Less than or equal 5 <= 5 True
>= Greater than or equal 4 >= 5 False

Don’t confuse = (assignment) with == (comparison).

x = 10       # assigns 10 to x
x == 10      # checks if x equals 10 → True

Common Pitfalls

Mistake Why it happens Fix
x = "5" then x + 1 fails Can’t add string and int int(x) + 1
5 == "5" is False Different types are not equal Convert types first
Variable name starts with a number Invalid Python syntax Start with a letter
Using = instead of == in a condition = is assignment, not comparison Use ==