Coding

Getting Started with Python for Statistics (Week 1)

YN
yNeedthis
Author
Getting Started with Python for Statistics

If you’ve ever wanted to learn statistics but felt overwhelmed by formulas, this series is for you.

Instead of starting with theory, we’ll start with something more practical: using Python to explore real data.

In today’s post, I’ll focus on why Python has become the go-to language for statistical analysis and how you can get started on your journey.

Whether you’re coming from Excel, R, or diving into statistics for the first time, Python offers a powerful yet beginner-friendly ecosystem for data analysis.

📑 In This Article

  1. Why Choose Python for Statistics?
  2. Setting Up Your Environment
  3. Essential Python Basics
  4. Your First Statistical Analysis
  5. What’s Coming Next

Why Choose Python for Statistics?

When I first started doing statistical analysis, I bounced between different tools: Excel for quick calculations, R for deeper analysis, and other software for specific tasks.

But Python changed everything.

Python isn’t just a statistics tool; it’s a full programming language. This means you can:

  • Collect data (APIs, scraping)
  • Clean and transform it
  • Analyze it
  • Build models
  • Even deploy results

All in one place.

The learning curve is also surprisingly gentle. Python reads almost like English:

mean = data.mean()

Compared to more complex statistical tools, this simplicity makes a big difference, especially when you’re learning both programming and statistics at the same time.

Setting Up Your Environment

Let’s get you up and running quickly. I recommend using Anaconda, which comes pre-loaded with everything you need.

Step 1: Install Anaconda (Mac & Windows)

  1. Go to https://www.anaconda.com/download

🍎 Mac

  • Download the Mac version (choose Apple Silicon or Intel based on your device)
  • Open the downloaded .pkg file
  • Follow the installation steps
  • Once installed, open Anaconda Navigator from your Applications folder

🪟 Windows

  • Download the Windows version
  • Run the .exe installer
  • Follow the installation steps (you can keep the default settings)
  • Once installed, open Anaconda Navigator from the Start Menu

💡 Tip:
Anaconda includes Python and essential data libraries, so you don’t need to install anything separately.

Step 2: Open Spyder (Recommended)

Inside Anaconda Navigator:

  • Launch Spyder
Anaconda navigator

Spyder is ideal for beginners because it gives you:

  • A code editor
  • A console (to run code)
  • A variable explorer (like a spreadsheet view of your data)
sypder console

This makes it especially useful for statistical work.

(Optional) Step 3: Use Jupyter Notebook

If you prefer an interactive format:

jupyter notebook

Jupyter lets you mix:

  • Code
  • Notes
  • Output

Think of it as a digital notebook for your analysis.

Step 4: Verify Your Setup

Run this in Spyder or Jupyter:

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

print("Ready for statistics!")

If this works without errors, you’re ready to go.

⚠️ Common Installation Issues (and Fixes)

Even though Anaconda is beginner-friendly, you might run into a few small issues. Here’s how to fix them quickly.

1. “Command not found” (Mac Terminal)

If you try running Python or jupyter notebook In Terminal, and get an error:

Fix:

  • Make sure Anaconda is installed properly
  • Use Anaconda Navigator instead of Terminal at first
  • Or restart your computer after installation

2. Anaconda Navigator won’t open

Fix:

  • Restart your Mac or Windows machine
  • Reinstall Anaconda if needed
  • On Windows, try “Run as Administrator”

3. Spyder not launching

Fix:

  • Open Anaconda Navigator first
  • Launch Spyder from there (not directly)
  • Update Spyder inside Navigator if needed

4. “Module not found” errors (numpy, pandas, etc.)

If you see errors like:

ModuleNotFoundError: No module named 'pandas'

Fix:

  • Open Anaconda Navigator
  • Go to Environments
  • Search for the missing package (e.g., pandas)
  • Install it

💡 Pro Tip

If things feel confusing at first, don’t panic. This is normal.

Most issues come from:

  • Not restarting after installation
  • Launching tools outside Anaconda Navigator

Once everything is opened through Anaconda, things usually work smoothly.

Essential Python Basics

We’ll only cover what you actually need to get started.

Variables

age = 25
name = "Alex"
salary = 55000

Data Types

integer = 10
float_num = 10.5
text = "hello"
is_valid = True

Comments

# This is a comment
age = 25  # storing age

Functions (Basic Idea)

print("Hello World")

You’ll mostly use built-in functions for now.

Importing Libraries

import pandas as pd

This loads the pandas library, which we’ll use for data analysis.

Your First Statistical Analysis

Now let’s actually do something with data.

Step 1: Load a Dataset

import pandas as pd

df = pd.read_csv("data.csv")

👉 This loads your dataset into a structure called a DataFrame (think Excel table).

Step 2: Preview the Data

df.head()

This shows the first 5 rows, so you can quickly understand what you’re working with.

Step 3: Get Statistical Summary

df.describe()

This is where things get interesting.

Instead of manually calculating statistics, Python gives you everything instantly:

  • Mean (average)
  • Standard deviation (spread)
  • Minimum / Maximum
  • Quartiles

🧠 How to Think About This

Don’t worry about formulas yet.

Just think:

  • Mean → typical value
  • Min / Max → range
  • Standard deviation → how spread out the data is

This is your first real look into the behaviour of your data.

💡 Why This Matters

With just a few lines of code, you can:

  • Understand trends
  • Spot unusual values
  • Prepare for deeper analysis

This is the foundation of statistical thinking.

What’s Coming Next

In Week 2, we’ll go further:

  • Clean messy data
  • Filter and transform datasets
  • Handle missing values
  • OLS Regression

🚀 Final Takeaway

You don’t need to master Python to start doing statistics.

Here is what you will need:

  • A few core concepts
  • The right tools
  • And real data

We’ll build everything else step by step.

The beauty of learning statistics with Python is that you’re not just learning statistical concepts, you’re learning a valuable programming skill that extends far beyond statistics. The investment you make in learning Python for statistics will pay dividends in automation, web development, machine learning, and countless other domains.

Thanks for reading 🙂

YN

yNeedthis

I’m Shareeza Hussain, a Software Engineer with 8+ years of experience building web applications across startups and emerging tech companies. I hold a Bachelor’s degree in Computer Science, postgraduate credentials in User Experience Design and Enterprise Software Development, and I’m currently pursuing a certification in Data Analytics for Behavioural Insights at the University of Waterloo. My work spans product-focused development, mentoring junior engineers, overseeing outsourced teams, and continuously testing new tools and technologies. This blog documents what I learn through hands-on experimentation — from coding and databases to AI-powered developer tools.

One comment on “Getting Started with Python for Statistics (Week 1)

Leave a Reply

Your email address will not be published. Required fields are marked *