# Data Science Cheat Sheet: Python, Stats & ML Tools

> A data science cheat sheet covering Python libraries, key statistics concepts, and ML algorithms. Bookmark this before your next project or job interview.

Data Science Cheat Sheet: Python, Stats & ML in One Place

# Data Science Cheat Sheet: Python, Stats & ML in One Place

Course Careers editorial team

April 12, 2026

June 27, 2026

Pandas has over 200 methods. NumPy adds another 400+. Nobody memorizes them all — but knowing which 20 cover 80% of real-world work is the difference between a productive analysis session and a morning lost in documentation. This data science cheat sheet cuts through the noise and gives you the commands, concepts, and decision rules that actually come up — in projects, in interviews, and on the job.

Bookmark it. Refer back to it. It covers Python for data work, the statistics you cannot afford to get wrong, a machine learning algorithm selector, and a data wrangling checklist you can run before any project.

## What a Data Science Cheat Sheet Should Actually Cover

Most cheat sheets online are either too shallow (a list of library names) or too deep (a 40-page PDF nobody reads). A useful data science cheat sheet focuses on five areas:

- Python syntax for data work — the specific pandas, NumPy, and scikit-learn operations you use constantly

- Statistics fundamentals — the concepts interviewers probe and that real analysis depends on

- Machine learning algorithm selection — when to use which model, not just what the model does

- Data wrangling steps — the checklist that keeps your pipeline clean

- Visualization defaults — the right chart for the right data type

This guide covers all five. Skip to any section you need.

## Data Science Cheat Sheet: Python Libraries

Python is the default language for data science. These are the operations you will use on nearly every project.

### pandas — Data Manipulation

```
import pandas as pd

df = pd.read_csv('data.csv')          # load data
df.head()                              # first 5 rows
df.info()                              # column types, nulls
df.describe()                          # summary statistics

# Selection
df['col']                              # single column (Series)
df[['col1','col2']]                    # multiple columns
df.loc[0:5, 'col']                     # label-based slice
df.iloc[0:5, 0:3]                      # integer-based slice
df[df['col'] > 100]                    # filter rows

# Cleaning
df.isnull().sum()                      # count nulls per column
df.dropna()                            # drop rows with any null
df.fillna(0)                           # fill nulls with 0
df.drop_duplicates()                   # remove duplicate rows
df['col'] = df['col'].astype('int')    # change dtype

# Transforming
df.groupby('cat')['val'].mean()        # group average
df.sort_values('col', ascending=False) # sort
df.merge(df2, on='id', how='left')     # join tables
df.rename(columns={'old':'new'})        # rename
df['new'] = df['a'] + df['b']          # new column
```

### NumPy — Numerical Computing

```
import numpy as np

arr = np.array([1, 2, 3, 4, 5])
arr.mean()      # 3.0
arr.std()       # standard deviation
arr.reshape(5,1)  # change shape

np.zeros((3,3))   # 3x3 matrix of zeros
np.linspace(0, 1, 100)  # 100 evenly spaced values 0–1
np.random.seed(42)       # reproducible randomness
np.random.randn(100)     # 100 samples from standard normal
```

### scikit-learn — Machine Learning

```
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import accuracy_score, classification_report

X_train, X_test, y_train, y_test = train_test_split(
    X, y, test_size=0.2, random_state=42
)

scaler = StandardScaler()
X_train = scaler.fit_transform(X_train)
X_test  = scaler.transform(X_test)      # NEVER fit on test

model = LogisticRegression()
model.fit(X_train, y_train)
preds = model.predict(X_test)
print(accuracy_score(y_test, preds))
print(classification_report(y_test, preds))
```

### Quick Visualization Reference

| Chart type | When to use | Library call |

| --- | --- | --- |

| Histogram | Distribution of one numeric variable | df['col'].hist() |

| Bar chart | Compare categories | df.groupby('cat')['val'].mean().plot.bar() |

| Scatter plot | Relationship between two numeric variables | df.plot.scatter('x','y') |

| Box plot | Distribution + outliers by category | df.boxplot(column='val', by='cat') |

| Heatmap | Correlation matrix | sns.heatmap(df.corr(), annot=True) |

| Line chart | Time series | df.plot(x='date', y='val') |

## Statistics Cheat Sheet for Data Scientists

This is where most self-taught practitioners have gaps. The following concepts appear constantly in analysis and interviews.

### Descriptive Statistics

- Mean — average; sensitive to outliers

- Median — middle value; robust to outliers; use for skewed distributions

- Mode — most frequent value; useful for categorical data

- Variance — average squared deviation from the mean

- Standard deviation — square root of variance; same units as original data

- IQR (interquartile range) — Q3 − Q1; standard outlier boundary is 1.5×IQR

### Key Distributions

- Normal — bell curve; 68% within 1σ, 95% within 2σ, 99.7% within 3σ

- Binomial — count of successes in N binary trials

- Poisson — count of events in a fixed time interval (web traffic, support tickets)

- Uniform — all values equally likely; good for random sampling

### Hypothesis Testing

- p-value — probability of observing results at least as extreme as yours if the null hypothesis is true. p < 0.05 is the conventional rejection threshold.

- t-test — compare means of two groups; assumes approximate normality

- chi-square test — association between two categorical variables

- ANOVA — compare means across 3+ groups

- Type I error — false positive (rejecting a true null)

- Type II error — false negative (failing to reject a false null)

### Correlation vs Causation

Correlation measures the linear relationship between two variables (r = −1 to +1). An r above 0.7 or below −0.7 is generally considered strong. Correlation never implies causation — always look for confounders before drawing conclusions.

## Machine Learning Algorithm Selector

Picking the wrong algorithm wastes time. Use this section of the data science cheat sheet as your first filter.

### Supervised Learning

| Algorithm | Problem type | When to try it first |

| --- | --- | --- |

| Linear Regression | Regression | Continuous target, you need interpretability |

| Logistic Regression | Classification | Binary target, need probability outputs, interpretable |

| Decision Tree | Both | Non-linear patterns, very interpretable, small data |

| Random Forest | Both | Default choice for tabular data; handles missing values and mixed types well |

| Gradient Boosting (XGBoost, LightGBM) | Both | Best accuracy on tabular data in competitions and production |

| SVM | Classification | High-dimensional data (text, images); slow on large datasets |

| KNN | Both | Small datasets, recommendation baselines; terrible at scale |

### Unsupervised Learning

| Algorithm | Use case | Watch out for |

| --- | --- | --- |

| K-Means | Customer segmentation, grouping | You must specify k; assumes spherical clusters |

| PCA | Dimensionality reduction, visualization | Components lose interpretability |

| DBSCAN | Anomaly detection, arbitrary-shaped clusters | Sensitive to epsilon and min_samples params |

### Model Evaluation Metrics

- Regression: MAE (mean absolute error), RMSE (root mean squared error), R²

- Classification: accuracy, precision, recall, F1-score, AUC-ROC

- Rule of thumb: use F1 when classes are imbalanced; use AUC-ROC when ranking matters more than a threshold decision

## Data Wrangling Checklist

Run through this before modeling on any new dataset:

1. Load and inspect — df.shape, df.dtypes, df.head()

2. Check missing values — df.isnull().sum(). Decide: drop, impute with mean/median/mode, or flag with an indicator column

3. Check for duplicates — df.duplicated().sum(); drop if structural, investigate if unexpected

4. Identify outliers — boxplots + IQR rule; decide based on domain knowledge whether they are errors or real extremes

5. Fix dtypes — dates should be datetime, categoricals as category or encoded int, not object

6. Feature engineering — extract month/day from dates, create ratio features, bin continuous variables if needed

7. Encode categoricals — one-hot encode low-cardinality columns; target-encode high-cardinality ones

8. Scale features — StandardScaler for algorithms that use distances (KNN, SVM, PCA); not needed for tree models

9. Split before any further processing — fit scalers and encoders only on training data; transform test data with the fitted objects

## Top Courses to Build on This Cheat Sheet

A cheat sheet gets you oriented. These courses build the depth that turns reference knowledge into working skill.

### Introduction to Data Analytics

A well-structured starting point covering the full data analysis workflow — from asking the right business questions to presenting findings. Strong on the Excel and SQL fundamentals that underpin most real-world data work before you ever touch Python.

### Executive Data Science Specialization

Covers data science from a strategic and managerial lens — ideal if you need to lead data projects, communicate findings to stakeholders, or understand what your team is building. Taught by Johns Hopkins faculty.

### Applied Plotting, Charting & Data Representation in Python

Goes far beyond the basics of matplotlib. Teaches principles of visual communication for data and builds real fluency with Python visualization — a skill most data scientists underinvest in.

### COVID-19 Data Analysis Using Python

A project-based course where you work with a real, messy public dataset. Excellent for practicing pandas wrangling and exploratory analysis in a context where the data behavior actually matters.

### Database Design and Basic SQL in PostgreSQL

SQL is the skill that bridges data science and data engineering — and most ML practitioners are weaker here than they should be. This course covers schema design and query writing in PostgreSQL, the most transferable SQL dialect.

### Introduction to Data Analysis using Microsoft Excel

Excel still dominates in many business environments. This course teaches pivot tables, statistical functions, and charting — a practical addition for anyone who needs to collaborate with non-technical stakeholders.

## FAQ

### What should a data science cheat sheet include?

At minimum: Python library syntax (pandas, NumPy, scikit-learn), core statistics concepts (distributions, hypothesis testing, correlation), an algorithm selection guide, and a data wrangling checklist. A good cheat sheet is reference material, not a tutorial — it should remind you of something you've learned, not teach it from scratch.

### Is Python or R better for data science?

Python is the dominant choice for production data science, machine learning, and data engineering. R remains strong in academic statistics and certain fields like bioinformatics and econometrics. If you're choosing one to learn first, Python has better job market coverage and a larger ecosystem of tools and libraries.

### How long does it take to become job-ready in data science?

With consistent daily practice (1–2 hours), most people can build a competitive portfolio within 6–12 months. The critical milestones are: functional Python/pandas fluency, SQL competence, at least two end-to-end project walkthroughs, and comfort explaining your analysis process out loud. Credentials help but projects close more offers.

### What statistics do you actually need for data science?

In practice: descriptive statistics, probability distributions (especially normal and binomial), basic hypothesis testing (t-test, chi-square, p-value interpretation), correlation, and linear regression assumptions. Advanced topics like Bayesian inference and time-series econometrics matter in specialist roles but are not required at entry level.

### Do I need a degree to work in data science?

A degree helps but isn't required. Hiring decisions increasingly weigh portfolio projects, technical screen performance, and certifications alongside formal credentials. Many working data scientists are self-taught or transitioned from adjacent fields (software engineering, finance, biology). A strong GitHub portfolio with documented, clean notebooks often outperforms a degree with no projects behind it.

### What are the most common data science interview topics?

SQL (joins, window functions, aggregations), Python pandas manipulation, statistics (especially p-values and A/B testing), probability questions, ML algorithm trade-offs, and one or two case study problems where you walk through how you'd approach an ambiguous business problem with data. The cheat sheet above covers the core of what interviewers probe.

## Bottom Line

A data science cheat sheet is most useful when it maps to how you actually work — not as a comprehensive encyclopedia but as a fast lookup for the commands, concepts, and decisions that come up repeatedly. The Python operations in this guide (pandas, NumPy, scikit-learn) cover the majority of real analysis work. The statistics section covers what interviewers test. The algorithm selector gives you a starting point so you don't default to the same model every time.

If you're building on this foundation, the Introduction to Data Analytics course is the best next step for grounding theory in practice, and the Applied Plotting & Data Representation course will sharpen the visualization skills most practitioners skip. Come back to this cheat sheet whenever you need a quick reference — that's exactly what it's here for.

## Looking for the best course? Start here:

- Best Data Science Certifications in 2026: Which Ones Actually Get You Hired

- Free Data Science Courses: Best Options to Start in 2026

- Data Science Certification: Which Ones Actually Help You Get Hired

## Related Articles

Articles

### Best Online Data Science Courses in 2026: What Actually Works

Data science has become one of the most sought-after skill sets in the modern job market, combining statistics, programming, and business acumen to extract valu

Read More »

Articles

### How to Become a Machine Learning Engineer in 2026

Machine learning represents one of the most transformative technologies of our era, enabling computers to learn from data and make intelligent predictions witho

Read More »

Articles

### How to Learn Programming: A Complete Beginner's Guide

Learning programming is an exciting journey that opens doors to countless career opportunities and creative possibilities. Whether you're interested in building

Read More »

### More in this category

- If You Want to Learn Python: A Complete Beginner's Guide

- IT Courses: Where to Learn Online

- Best Data Science Course in 2026: What Actually Gets You Hired

- Best Machine Learning Engineer Courses (Ranked and Reviewed)

- Learn AI Programming: A Complete Guide to Getting Started

- Learn AI Programming Basics: Getting Started Guide

- Java Certification: Oracle OCP Path, Exam Prep, and Career Value