Python for Data Science Certification Cheat Sheet: Key Concepts at a Glance

Author : mahesh 2003 | Published On : 21 Nov 2026

Here is a compact, exam-ready Python for Data Science Certification Cheat Sheet organizing core syntax, numerical arrays, tabular data wrangling, visualization, statistics, and machine learning workflows at a glance.

1. Python Core & Data Structures

  • Types & Casting: int, float, str, bool; convert via int(), float(), str(), bool().
     

  • Collections:

    • list ([1, 2, 3]): ordered, mutable; .append(), .pop(), slicing arr[start:stop:step].

    • tuple ((1, 2, 3)): ordered, immutable; good for fixed records or return values.

    • dict ({"k": "v"}): key-value lookup; .keys(), .values(), .items(), .get("k", default).

    • set ({1, 2, 3}): unordered unique items; set operations (|, &, -) for deduplication and membership checks.
       

  • Comprehensions & Functions: [x * 2 for x in items if x > 0], {k: v for ...}, def fn(a, b=1):, lambda x: x + 1, and try ... except Exception as e: for safe error handling.
     

2. NumPy Essentials (import numpy as np)

  • Creation & Inspection: np.array(), np.zeros(), np.ones(), np.arange(0, 10, 2), np.linspace(0, 1, 5); check .shape, .ndim, .dtype, .size.

  • Indexing & Masking: arr[r, c], slice arr[1:4, :2], boolean filter arr[arr > 0], np.where(cond, val_if_true, val_if_false).

  • Math & Aggregations: Element-wise ops and broadcasting across compatible shapes; np.mean(), np.median(), np.std(), np.percentile(), np.sum(axis=0) (down rows) vs. axis=1 (across columns).

3. Pandas Data Wrangling (import pandas as pd)

  • Inspecting DataFrames: df.head(), df.info(), df.describe(), df.shape, df.columns, df.isna().sum(), df.duplicated().sum().

  • Selection & Filtering:

    • df.loc[row_label, col_label] (label-based + boolean masks).

    • df.iloc[row_idx, col_idx] (integer position-based).

    • Filter example: df[(df["age"] >= 18) & (df["status"] == "active")].

  • Cleaning & Types:

    • Missing values: df.dropna(subset=["col"]) or df["col"].fillna(val).

    • Duplicates & types: df.drop_duplicates(), pd.to_datetime(df["date"]), df["cat"].astype("category").

  • Aggregation & Combining:

    • df.groupby("grp").agg(mean_val=("val", "mean"), count_rows=("id", "count")).

    • pd.merge(left_df, right_df, on="key", how="left") (check row counts before and after to spot join explosion).

    • Reshaping: df.pivot_table(values="y", index="row_k", columns="col_k", aggfunc="mean") and df.melt(...).

4. Visualization Quick Reference (Matplotlib & Seaborn)

Goal

Best Chart Types

Key Practice

Single-variable distribution

Histogram, KDE, Box plot, Violin plot

Check skew, outliers, and bin width; use fig, ax = plt.subplots().

Category comparison

Bar chart, Horizontal bar, Grouped/stacked bar

Sort bars when order isn't ordinal; start bar axes at zero.

Two-variable relationship

Scatter plot, Hexbin, Line chart

Label axes with units; add trend/reference lines sparingly.

Multi-variable / matrix

Correlation heatmap, Pair plot

Mask redundant cells or annotate clearly; avoid rainbow colormaps.

5. Statistics & Scikit-learn Workflow (sklearn)

  • Statistics & EDA: Compare mean vs. median under skew; measure spread with std/IQR; check correlation (Pearson for linear, Spearman for rank/monotonic) without assuming causation.

  • Leak-Free Modeling Steps:

    • Split first: X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42, stratify=y) (use stratify=y for classification).

    • Preprocess inside a pipeline: Use ColumnTransformer with Pipeline([("imputer", SimpleImputer(...)), ("scaler", StandardScaler())]) for numeric features and OneHotEncoder(handle_unknown="ignore") for categoricals.

    • Fit & cross-validate: Wrap preprocessing + estimator (LogisticRegression, RandomForestClassifier, Ridge, HistGradientBoostingClassifier, etc.) in a single Pipeline, then evaluate with cross_val_score / cross_validate.

  • Picking Evaluation Metrics:

    • Regression: MAE (robust to outliers), RMSE (penalizes large errors in target units), R² (explained variance).

    • Classification: Precision (false-positive cost), Recall (false-negative / missed-case cost), F1, ROC-AUC, and confusion matrix—avoid accuracy alone on imbalanced classes.

High-Frequency Exam & Data Science Interview Question Gotchas

  • Data leakage: Never fit scalers, imputers, or encoders on the full dataset or test set before splitting.

  • Chained assignment warnings: Prefer .loc[mask, "col"] = val over chained indexing like df[mask]["col"] = val.

  • Tree vs. linear/distance scaling: Tree splits are invariant to monotonic scaling; linear models, SVMs, KNN, and neural nets are sensitive to feature scale and outliers.

  • Overfitting vs. underfitting: High training score + weak validation score = high variance (overfitting); poor training score = high bias (underfitting).