Python DS
IntermediateData Science Β· Machine Learning Β· AI
Python is the #1 language for data science, machine learning, and AI. Libraries like NumPy, Pandas, Matplotlib and scikit-learn give you a complete toolkit β from raw data to trained model β with concise, readable code.
The Process
Data Science Pipeline
Every data science project follows this 6-step flow. Python has libraries for each stage.
Ecosystem
Core Libraries
import numpy as npN-dimensional arrays with vectorised math β the foundation everything else builds on.
pip install numpyimport pandas as pdDataFrame-based data manipulation and analysis β like Excel but with code.
pip install pandasimport matplotlib.pyplot as pltThe foundational plotting library β full control over every chart element.
pip install matplotlibimport seaborn as snsStatistical visualisation on top of Matplotlib β beautiful charts with less code.
pip install seabornfrom sklearn.linear_model import LinearRegressionThe standard machine learning library β dozens of algorithms, preprocessing, and evaluation tools.
pip install scikit-learnfrom scipy import statsScientific computing β statistics, optimisation, signal processing, linear algebra.
pip install scipypip install numpy pandas matplotlib seaborn scikit-learn scipy jupyter
# Or with conda (recommended for DS):
conda create -n ds python=3.12
conda activate ds
conda install numpy pandas matplotlib seaborn scikit-learn scipy jupyterCheat Sheet
Quick Reference
Click any row to copy the syntax
| Concept | Syntax | Notes |
|---|---|---|
| Create array | np.array([1,2,3]) | From list |
| Zeros / ones | np.zeros((3,4)) np.ones((2,3)) | Fill with 0 or 1 |
| Range | np.arange(0, 10, 2) np.linspace(0,1,5) | Step / evenly spaced |
| Random | np.random.randn(3,3) np.random.randint(1,10) | Normal / integer |
| Shape / reshape | a.shape a.reshape(3,4) | Dimensions |
| Indexing / slicing | a[0] a[1:3] a[a > 5] | Boolean mask |
| Math ops | a + b a * b np.dot(a,b) | Elementwise + matrix multiply |
| Stats | a.mean() a.std() a.sum(axis=0) | Axis 0=cols, 1=rows |
Ready to analyse data?
The full tutorial walks through 6 modules β NumPy arrays, Pandas DataFrames, data cleaning, visualisation, machine learning, and a complete end-to-end project.
Also in Data Science & AI
The Story of Python for Data Science
Real history, real companies, and an honest look at where Python for Data Scienceshines and where it doesn't β not just a feature list.
Where it came from
Python wasn't originally built for data science at all β that came later, driven by community-built libraries. NumPy (2006) brought fast numerical arrays to Python, pandas (2008, built by Wes McKinney at a hedge fund) added spreadsheet-like data manipulation, and by the mid-2010s this ecosystem had made Python the default language for data work almost by accident of good tooling.
How itβs actually used today
Netflix's recommendation algorithm, Spotify's Discover Weekly playlists, and most published academic machine learning research all run on this Python data stack β pandas for cleaning data, NumPy for numerical operations, and TensorFlow or PyTorch for the machine learning models themselves. It's also the standard toolkit taught in university data science courses worldwide.
Strengths & trade-offs
The ecosystem's biggest advantage is that pandas and NumPy are actually implemented in fast, compiled C code underneath β so despite Python's reputation for being slow, real data science workloads run efficiently because the heavy lifting happens outside plain Python. The trade-off is a real learning curve: pandas' syntax and mental model take genuine practice, separate from learning core Python itself.
What to learn next
SQL comes next for almost everyone doing real data work, since raw data usually lives in a database before it ever reaches pandas. From there, a specific direction β statistics and visualisation, or machine learning specifically β is where most people branch off.