Choosing Tools & Learning Path
|
This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production. |
Data science has an unusual number of overlapping tools. Most of them can do most jobs, and the wrong choice is rarely fatal, but it can cost weeks of friction. This page gives decision rules instead of a ranking: for each common choice it states the question that decides it, a table of the trade-offs, and where relevant a short runnable example. It closes with a staged learning path through the pages of this section.
Examples target Python 3.13 or 3.14 and were run on Python 3.13. The recommendations target NumPy 2.5, pandas 3.1 and scikit-learn 1.9, and were checked in October 2026 against the versions Polars 2.1, DuckDB 2.0, statsmodels 0.15, Matplotlib 3.11, seaborn 0.13.2 and Plotly 7.1. All Python snippets were run with those versions on 2026-10-31. The libraries beyond the core are introduced in Beyond the Core: Polars, Arrow, DuckDB & Deep Learning; this page assumes you have at least skimmed it.
How to decide
Four questions settle most choices, in this order:
-
What is the data size relative to memory? A table that fits in memory (a few hundred megabytes up to a few gigabytes, depending on the machine) leaves every engine open. A table several times larger than memory needs an engine that streams or spills to disk.
-
What does the team already know? A team fluent in SQL, or in R, moves faster in its own language than in a theoretically better tool.
-
What must the result be? A one-off answer, a repeatable report, a model, a service and a published figure need different tools.
-
What must be explained? If decisions rest on parameters and their uncertainty, an inferential tool fits. If only predictive accuracy matters, a predictive one does.
The default when in doubt is the core stack: pandas for tables, scikit-learn for models, Matplotlib and seaborn for charts, in a notebook while exploring and a script once the work repeats. Change a default only when one of the four questions gives a concrete reason.
Tables: pandas, Polars, DuckDB or SQL
The four options differ in where the computation runs and in how the query is written.
| Option | Strengths | Costs | Choose it when |
|---|---|---|---|
pandas 3.1 |
The largest ecosystem; every library accepts it; index-aware operations; rich time series and plotting; Copy-on-Write
and the |
Eager and mostly single-threaded; memory use is a multiple of the file size for text-heavy data; the index and alignment rules surprise newcomers. |
The data fits in memory, the next step is scikit-learn, statsmodels or seaborn, or you are learning. |
Polars 2.1 |
Expressions, lazy query optimisation, multi-threaded execution, a streaming engine, strict types and real nulls. |
Smaller ecosystem; different idioms from pandas; conversions at the boundary with libraries that expect pandas. |
Large files, heavy group-by and join pipelines, repeatable ETL where an optimised plan pays off. |
DuckDB 2.0 |
Full analytical SQL in process; queries Parquet and CSV in place; spills to disk; reads pandas, Polars and Arrow objects by name. |
Requires SQL; row-by-row Python logic is awkward; less natural for iterative feature engineering. |
The work is joins, windows and aggregations, the team prefers SQL, or the data is a folder of Parquet files. |
A database server and SQL |
The data already lives there; concurrency, security and transactions are solved; the query runs next to the data. |
Network round trips; feature engineering in SQL gets long; reproducing results needs the same database state. |
The data is too big or too sensitive to copy out, or other applications share it. |
The same aggregation in three of them, each producing the same answer, shows that the difference is style, not capability:
import duckdb
import pandas as pd
import polars as pl
data = {
"region": ["north", "south", "north", "east", "south", "north"],
"units": [3, 5, 2, 7, 1, 4],
"price": [2.5, 1.0, 2.5, 4.0, 1.0, 2.5],
}
# pandas 3.1
pdf = pd.DataFrame(data)
r_pd = (
pdf.assign(revenue=pdf["units"] * pdf["price"])
.groupby("region", as_index=False)["revenue"]
.sum()
.sort_values("revenue", ascending=False, ignore_index=True)
)
# Polars 2.1
r_pl = (
pl.DataFrame(data)
.with_columns((pl.col("units") * pl.col("price")).alias("revenue"))
.group_by("region")
.agg(pl.col("revenue").sum())
.sort("revenue", descending=True)
)
# DuckDB 2.0 (SQL)
r_db = duckdb.sql(
"""
SELECT region, sum(units * price) AS revenue
FROM pdf
GROUP BY region
ORDER BY revenue DESC
"""
).df()
print(r_pd)
print(r_pl)
print(r_db)
region revenue
0 east 28.0
1 north 22.5
2 south 6.0
shape: (3, 2)
┌────────┬─────────┐
│ region ┆ revenue │
│ --- ┆ --- │
│ str ┆ f64 │
╞════════╪═════════╡
│ east ┆ 28.0 │
│ north ┆ 22.5 │
│ south ┆ 6.0 │
└────────┴─────────┘
region revenue
0 east 28.0
1 north 22.5
2 south 6.0
The pandas result carries a default integer index and Polars prints its dtypes, but the numbers agree. When a task is small, choose by readability for your team. Performance differences appear with large inputs and many cores, and they depend on the query, so measure before migrating; the pandas side of the comparison is covered in Data Cleaning & Preparation and the SQL side in the site’s aggregate and window functions page.
Source: pandas, group by, Polars, aggregation and DuckDB, GROUP BY.
A flowchart of the decision:
The chart is a starting rule, not an order. Many projects use two engines: DuckDB or Polars to reduce a large dataset, then pandas for the final modelling table.
Models: scikit-learn, statsmodels, gradient boosting or PyTorch
The question here is what the model is for.
| Tool | Strengths | Costs | Choose it when |
|---|---|---|---|
scikit-learn 1.9 |
One API for dozens of estimators, pipelines, cross-validation, search, metrics and persistence helpers; includes
|
Little inferential output (no standard errors or p-values); not for deep networks or GPU training of large models. |
The goal is prediction on tabular data, you need a baseline, or you need a clean evaluation workflow. |
statsmodels 0.15 |
Regression and time series models with coefficient tables, standard errors, confidence intervals and diagnostics; formula interface. |
Less automation for tuning and pipelines; fewer algorithms than scikit-learn. |
The goal is to explain or test relationships, or report uncertainty on parameters. |
XGBoost, LightGBM |
Strong accuracy on tabular data; scikit-learn-compatible estimators; GPU and large-data options. |
More hyper-parameters; extra dependencies (on macOS, LightGBM needs the OpenMP runtime). |
A baseline from scikit-learn is not accurate enough and the data is tabular. |
PyTorch, Keras |
Neural networks for images, audio, text and sequences; GPU support; pretrained models. |
More code, more data and more compute; harder to explain; careful validation is essential. |
The inputs are unstructured, or you fine-tune a pretrained model. |
scikit-learn and statsmodels answer different questions on the same data. The next example fits the same linear model with both; the prediction tool reports the coefficients and a score, the inference tool also reports how uncertain each coefficient is, including that the second feature (whose true effect is zero) is not significant.
import numpy as np
import statsmodels.api as sm
from sklearn.linear_model import LinearRegression
rng = np.random.default_rng(42)
X = rng.normal(size=(200, 2))
y = 1.0 + 2.0 * X[:, 0] + 0.0 * X[:, 1] + rng.normal(scale=1.0, size=200)
# scikit-learn: prediction-oriented API, no inference output
sk = LinearRegression().fit(X, y)
print("sklearn:", sk.intercept_.round(3), sk.coef_.round(3), "R2 =", round(sk.score(X, y), 3))
# statsmodels: inference-oriented API (standard errors, p-values, confidence intervals)
res = sm.OLS(y, sm.add_constant(X)).fit()
print(res.summary().tables[1])
sklearn: 0.931 [ 1.982 -0.053] R2 = 0.788
==============================================================================
coef std err t P>|t| [0.025 0.975]
------------------------------------------------------------------------------
const 0.9305 0.072 12.886 0.000 0.788 1.073
x1 1.9822 0.073 27.048 0.000 1.838 2.127
x2 -0.0533 0.079 -0.674 0.501 -0.209 0.103
==============================================================================
Both fits give identical coefficients; they differ in what comes with them. This is the reason a model that is only ever evaluated by held-out accuracy belongs in scikit-learn, while a model whose coefficients are quoted in a report needs the statistics that statsmodels prints. See Statistics Fundamentals for the interpretation of those columns and Machine Learning Fundamentals for the predictive view.
A rule worth following regardless of the tool: build the simplest baseline first (a dummy predictor, then a linear or tree model), and let a more complex tool earn its place by beating it under honest validation, as described in Model Evaluation & Validation.
Charts: Matplotlib, seaborn or Plotly
The three libraries stack rather than compete: seaborn draws on Matplotlib, and Plotly is a separate interactive renderer.
| Library | Strengths | Costs | Choose it when |
|---|---|---|---|
Matplotlib 3.11 |
Complete control of every element; publication-quality static output; the base for most Python plotting. |
Verbose for statistical charts; defaults need styling. |
You need a precise static figure or a custom layout. |
seaborn 0.13.2 |
Statistical charts from a data frame in one call (distributions, relationships, categories); axes-level and figure-level functions; sensible defaults. |
Customisation falls back to Matplotlib; the project has been on 0.13.2 since January 2024 (current, not deprecated). |
Exploration, and figures that show groups and distributions. |
Plotly 7.1 |
Interactive hover, zoom and selection; HTML output; web dashboards. |
Larger output files; a different API; static export needs extra tooling. |
The audience will explore the chart, or it goes on a web page. |
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import plotly.express as px
import seaborn as sns
rng = np.random.default_rng(0)
df = pd.DataFrame({"x": rng.normal(size=100)})
df["y"] = 2 * df["x"] + rng.normal(size=100)
df["group"] = np.where(df["x"] > 0, "high", "low")
# Matplotlib: full control through Figure and Axes
fig, ax = plt.subplots(figsize=(4, 3))
ax.scatter(df["x"], df["y"], s=10)
ax.set(xlabel="x", ylabel="y")
fig.savefig("matplotlib.png", dpi=100)
# seaborn: statistical defaults on top of Matplotlib
grid = sns.relplot(data=df, x="x", y="y", hue="group", height=3)
grid.savefig("seaborn.png", dpi=100)
# Plotly: interactive HTML
fig_px = px.scatter(df, x="x", y="y", color="group")
fig_px.write_html("plotly.html", include_plotlyjs="cdn")
for name in ("matplotlib.png", "seaborn.png", "plotly.html"):
print(name, "written")
matplotlib.png written
seaborn.png written
plotly.html written
The first uses the explicit fig, ax = plt.subplots() interface, which is the one to learn first because it scales to
multi-panel figures. The three snippets draw the same scatter plot at three levels of abstraction. The Agg backend line
makes the script run without a display, which is what a script on a server needs; in a notebook, leave it out. The
chapter Data Visualization covers chart choice, colour accessibility and
the Matplotlib object model. A pitfall in older tutorials: fig.gca(projection="3d") was removed in Matplotlib 3.6;
write fig.add_subplot(projection="3d").
Source: Matplotlib, quick start, seaborn, introduction and Plotly Express.
Where the code lives: notebook or script
Notebooks and scripts are not rivals; they are two stages of one workflow.
| Situation | Prefer | Why |
|---|---|---|
Exploring a new dataset, trying ideas, teaching |
Notebook (JupyterLab) |
Fast feedback, inline output and charts, narrative next to code. |
Anything run on a schedule, in CI or on a server |
Script or package with a command-line entry point |
Reproducible, testable, no hidden state, easy to review. |
A report that must be regenerated |
Parameterised notebook (papermill) or Quarto |
Runs from top to bottom with fixed inputs and produces a document. |
Reusable logic |
Module imported by the notebook |
One tested copy instead of cells pasted between notebooks. |
Reviewing changes in version control |
Script, or notebook paired with Jupytext and stripped of outputs |
Diffs of JSON with embedded outputs are unreadable. |
A practical routine: explore in a notebook; when a cell stabilises, move it into a function in a module; keep the notebook as a thin layer that calls the module; before sharing, restart the kernel and run all cells, because hidden state and out-of-order execution are the main reason a notebook that worked yesterday fails today. See Jupyter Notebooks & JupyterLab for the details and for the environment and dependency side, Setting Up a Data Science Environment and lock files and reproducible installs. Editors and notebook tools are compared in Python IDEs and tools.
Language: Python or R
Both languages are mature for data science, and both can call each other. The choice is mostly about the surrounding work.
| Criterion | Python | R |
|---|---|---|
Statistics and classical modelling |
Good (SciPy, statsmodels), with fewer specialised packages. |
Excellent; many statistical methods appear in R first. See statistical models in R. |
Tabular data wrangling |
pandas, Polars, DuckDB. |
The tidyverse and |
Machine learning and deep learning |
The default: scikit-learn, XGBoost, PyTorch, Keras and most research code. |
Available (tidymodels, torch for R), a smaller community. |
Visualisation |
Matplotlib, seaborn, Plotly. |
ggplot2 is a strength. See ggplot2. |
Reports |
Jupyter, Quarto. |
R Markdown and Quarto. See Quarto and R Markdown. |
Production and services |
Strong: general-purpose language, web frameworks such as FastAPI. |
Possible (Plumber, Shiny), less common. |
Mixed teams |
|
|
A common outcome: Python for the pipeline and the model, R for a specialised statistical analysis or a particular chart, glued by Quarto or by files exchanged in Parquet or CSV. For the language itself see Getting started with Python and the R section.
A learning path through this section
The pages of this section build on each other. The path below suits a reader who knows basic Python.
| Stage | Goal | Read |
|---|---|---|
1. Orientation |
Know what data science is and what the work looks like. |
What Is Data Science?, The Data Science Workflow, The Scientific Python Stack |
2. Set up |
A reproducible environment and a notebook. |
Setting Up a Data Science Environment, Jupyter Notebooks & JupyterLab |
3. Arrays and tables |
Work fluently with NumPy and pandas. |
|
4. Data to insight |
Load, clean, explore and plot data. |
Data Sources & File Formats, Data Cleaning & Preparation, Exploratory Data Analysis, Data Visualization |
5. Statistics |
Quantify uncertainty and test claims. |
|
6. Modelling |
Build and honestly evaluate predictive models. |
Feature Engineering, Machine Learning Fundamentals, Model Evaluation & Validation, scikit-learn |
7. Professional practice |
Make work repeatable, shareable and responsible. |
Reproducibility & MLOps Basics, Ethics, Privacy & Responsible Data Use |
8. Beyond |
Larger data, other engines, deep learning. |
Beyond the Core, then What Is an LLM? and Hugging Face |
Stage 3 can start earlier or in parallel with stage 2. For reference while working, the Cheat Sheet collects the most used calls on one page for each library.
Three habits matter more than any tool choice: keep a fixed random seed and a held-out test set from the first model on; write down the question before opening the data; and share the environment (a lock file) with the code.
Common mistakes when choosing tools
-
Choosing for the benchmark. A faster engine matters only when time or memory is the actual constraint.
-
Choosing for the résumé. Deep learning on a few thousand tabular rows, or a cluster for a laptop-sized file, adds cost without adding accuracy.
-
Mixing versions. Combining a recent library with a tutorial written for an older major version produces errors that look like bugs in the tool. Check the version in the first lines of the article.
-
Ignoring the team. A pipeline nobody else can maintain is a liability, however elegant.
-
Skipping the baseline. Without a simple reference model, an accuracy figure has no meaning.
-
Following outdated books literally. Material from 2015 to 2019 presents Python 2 code,
sklearn.cross_validation,.ix,DataFrame.appendand Theano or TensorFlow 1 sessions, which no longer work on current versions. Use the concepts and take the code from current documentation.
See also
In the ML (Machine Learning) section: Choosing a Framework and Tabular Data: Gradient Boosting vs Deep Learning.