Skip to main content

A modular set of data science utilities for EDA, cleaning, and more.

Project description

๐Ÿง  data-science-snippets

data-science-snippets is a modular, production-ready Python library containing curated, reusable utilities used in the day-to-day workflows of senior data scientists and machine learning engineers.

It includes tools for EDA, cleaning, validation, text processing, feature engineering, visualization, model evaluation, time series, and more โ€” organized by task to keep your work clean and efficient.


๐Ÿš€ Features

โœ… Covers every major step in the data science lifecycle
โœ… Clean, modular structure by task
โœ… Built for reusability in real-world projects
โœ… Lightweight: only depends on pandas and numpy by default
โœ… Compatible with Python 3.9+


๐Ÿ“ Folder Structure

data-science-snippets/
โ”œโ”€โ”€ eda/
โ”‚   โ”œโ”€โ”€ most_frequent_values.py
โ”‚   โ”œโ”€โ”€ data_summary.py
โ”‚   โ”œโ”€โ”€ cardinality_report.py
โ”‚   โ””โ”€โ”€ basic_statistics.py
โ”œโ”€โ”€ data_cleaning/
โ”‚   โ”œโ”€โ”€ missing_data_summary.py
โ”‚   โ”œโ”€โ”€ outlier_detection.py
โ”‚   โ””โ”€โ”€ duplicate_removal.py
โ”œโ”€โ”€ preprocessing/
โ”‚   โ”œโ”€โ”€ minmax_scaling.py
โ”‚   โ”œโ”€โ”€ encoding.py
โ”‚   โ””โ”€โ”€ normalize_columns.py
โ”œโ”€โ”€ loading/
โ”‚   โ”œโ”€โ”€ load_csv_with_info.py
โ”‚   โ”œโ”€โ”€ safe_parquet_loader.py
โ”‚   โ””โ”€โ”€ load_large_file_chunks.py
โ”œโ”€โ”€ visualization/
โ”‚   โ”œโ”€โ”€ missing_data_heatmap.py
โ”‚   โ”œโ”€โ”€ distribution_plot.py
โ”‚   โ””โ”€โ”€ correlation_matrix.py
โ”œโ”€โ”€ feature_engineering/
โ”‚   โ”œโ”€โ”€ create_datetime_features.py
โ”‚   โ”œโ”€โ”€ binning.py
โ”‚   โ”œโ”€โ”€ interaction_terms.py
โ”‚   โ””โ”€โ”€ rare_label_encoding.py
โ”œโ”€โ”€ automated_eda/
โ”‚   โ”œโ”€โ”€ quick_eda_report.py
โ”‚   โ””โ”€โ”€ profile_report_wrapper.py
โ”œโ”€โ”€ model_evaluation/
โ”‚   โ”œโ”€โ”€ classification_report_extended.py
โ”‚   โ”œโ”€โ”€ confusion_matrix_plot.py
โ”‚   โ”œโ”€โ”€ cross_validation_metrics.py
โ”‚   โ””โ”€โ”€ roc_auc_plot.py
โ”œโ”€โ”€ text_processing/
โ”‚   โ”œโ”€โ”€ clean_text.py
โ”‚   โ”œโ”€โ”€ tokenize_text.py
โ”‚   โ””โ”€โ”€ tfidf_features.py
โ”œโ”€โ”€ time_series/
โ”‚   โ”œโ”€โ”€ lag_features.py
โ”‚   โ”œโ”€โ”€ rolling_statistics.py
โ”‚   โ””โ”€โ”€ datetime_indexing.py
โ”œโ”€โ”€ modeling/
โ”‚   โ”œโ”€โ”€ model_training.py
โ”‚   โ”œโ”€โ”€ pipeline_builder.py
โ”‚   โ””โ”€โ”€ hyperparameter_tuner.py
โ”œโ”€โ”€ serialization/
โ”‚   โ”œโ”€โ”€ save_model.py
โ”‚   โ”œโ”€โ”€ load_model.py
โ”‚   โ””โ”€โ”€ versioned_saver.py
โ”œโ”€โ”€ data_validation/
โ”‚   โ”œโ”€โ”€ schema_check.py
โ”‚   โ”œโ”€โ”€ unique_constraints.py
โ”‚   โ””โ”€โ”€ value_range_check.py
โ”œโ”€โ”€ utils/
โ”‚   โ”œโ”€โ”€ memory_optimization.py
โ”‚   โ”œโ”€โ”€ execution_timer.py
โ”‚   โ””โ”€โ”€ logging_setup.py
โ””โ”€โ”€ README.md

๐Ÿ”น eda/ โ€“ Exploratory Data Analysis

  • most_frequent_values.py: Shows the most common (modal) value per column, its frequency, and percent from non-null values.
  • data_summary.py: Summarizes dtypes, nulls, uniques, and memory usage for quick inspection.
  • cardinality_report.py: Reports high-cardinality columns in categorical features.
  • basic_statistics.py: Returns mean, median, min, max, std, and other summary statistics.

๐Ÿ”น data_cleaning/

  • missing_data_summary.py: Shows missing value count and percentage per column, along with data types.
  • outlier_detection.py: Detects outliers using IQR or Z-score methods.
  • duplicate_removal.py: Identifies and removes duplicate rows or records.

๐Ÿ”น preprocessing/

  • minmax_scaling.py: Scales numeric values to a [0, 1] range.
  • encoding.py: Label encoding and one-hot encoding utilities.
  • normalize_columns.py: Z-score standardization and column normalization helpers.

๐Ÿ”น loading/

  • load_csv_with_info.py: Loads CSVs and prints metadata like shape, dtypes, and missing values.
  • safe_parquet_loader.py: Robust parquet file loader with fallback options.
  • load_large_file_chunks.py: Loads large files in chunks with progress reporting.

๐Ÿ”น visualization/

  • missing_data_heatmap.py: Visualizes missing values with a Seaborn heatmap.
  • distribution_plot.py: Plots distributions of numeric variables.
  • correlation_matrix.py: Draws a correlation heatmap of numeric features.

๐Ÿ”น feature_engineering/

  • create_datetime_features.py: Extracts features like day, month, year, weekday from datetime columns.
  • binning.py: Performs binning (equal-width or quantile) on continuous variables.
  • interaction_terms.py: Creates interaction features (e.g., feature1 * feature2).
  • rare_label_encoding.py: Groups rare categorical labels into 'Other'.

๐Ÿ”น automated_eda/

  • quick_eda_report.py: Generates a summary of shape, dtypes, nulls, basic stats.
  • profile_report_wrapper.py: Wrapper for pandas-profiling / ydata-profiling report generation.

๐Ÿ”น model_evaluation/

  • classification_report_extended.py: Displays precision, recall, F1 with support for multiple averages.
  • confusion_matrix_plot.py: Annotated confusion matrix visual.
  • cross_validation_metrics.py: Computes metrics across folds and aggregates results.
  • roc_auc_plot.py: Plots ROC curve and calculates AUC score.

๐Ÿ”น text_processing/

  • clean_text.py: Removes punctuation, stopwords, numbers, and lowercases text.
  • tokenize_text.py: Word and sentence tokenizers with NLTK or spaCy support.
  • tfidf_features.py: Builds TF-IDF matrix from text columns.

๐Ÿ”น time_series/

  • lag_features.py: Generates lagged versions of a column for time-aware modeling.
  • rolling_statistics.py: Rolling mean, median, std, and min/max features.
  • datetime_indexing.py: Time-based slicing, filtering, and resampling helpers.

๐Ÿ”น modeling/

  • model_training.py: Trains scikit-learn models with optional cross-validation and logging.
  • pipeline_builder.py: Builds preprocessing + modeling pipelines using Pipeline or ColumnTransformer.
  • hyperparameter_tuner.py: Wraps GridSearchCV or RandomizedSearchCV with easy setup and evaluation.

๐Ÿ”น serialization/

  • save_model.py: Saves models and preprocessing pipelines using joblib or pickle.
  • load_model.py: Loads models with optional safety checks.
  • versioned_saver.py: Automatically versions and saves models or artifacts in organized directories.

๐Ÿ”น data_validation/

  • schema_check.py: Validates schema based on expected dtypes and column names.
  • unique_constraints.py: Ensures unique values for IDs or compound keys.
  • value_range_check.py: Checks for valid value ranges in numeric columns.

๐Ÿ”น utils/

  • memory_optimization.py: Downcasts numerical columns to save memory.
  • execution_timer.py: Times function execution with decorators or context managers.
  • logging_setup.py: Sets up consistent logging configuration for larger projects.

๐Ÿ“ฆ Installation

pip install data-science-snippets

Or install from source:

git clone https://github.com/vAndrewKarma/data-science-snippets.git
cd data-science-snippets
pip install -e .

๐Ÿ› ๏ธ Usage

from data_science_snippets.eda.most_frequent_values import most_frequent_values
from data_science_snippets.preprocessing.minmax_scaling import scale_dataframe
from data_science_snippets.modeling.pipeline_builder import build_pipeline

most_frequent_values(df)
scale_dataframe(df, columns=["age", "income"])
build_pipeline(...)

๐Ÿ“š Requirements

  • Python โ‰ฅ 3.9
  • pandas โ‰ฅ 1.5.3
  • numpy โ‰ฅ 1.24.4
  • seaborn โ‰ฅ 0.12.2
  • matplotlib โ‰ฅ 3.6.3

๐Ÿ” Security

Please see our SECURITY.md for vulnerability disclosure guidelines.


๐Ÿ‘ฅ Authors

  • Vataselu Andrei
  • Nicola-Diana Sincaru

๐Ÿ“„ License

This project is licensed under the MIT License. See the LICENSE file for details.


๐ŸŒŸ Contributions

We welcome contributions! If you have a reusable function or snippet that you think belongs in a senior data scientistโ€™s toolkit, feel free to open a pull request.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

axn_utils-0.3.1.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

axn_utils-0.3.1-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file axn_utils-0.3.1.tar.gz.

File metadata

  • Download URL: axn_utils-0.3.1.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for axn_utils-0.3.1.tar.gz
Algorithm Hash digest
SHA256 64766630fcc0faeaf222ef885bf6191d930ef0dde2bd721aa20c36aa99c1984b
MD5 1b063da3f4541696ebc45bdc93ee5392
BLAKE2b-256 513e321104b613ccaf3a67d0b796b9d5ae3f64016d9f1bbe802ea31c5ffaf45a

See more details on using hashes here.

File details

Details for the file axn_utils-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: axn_utils-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for axn_utils-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 82f780fe7afe6c48636759ef0ea05cbfb448cbb33c51c83cadddc65b37b7bb7b
MD5 a4938904f6deaf2aab92e7c3b1a0af72
BLAKE2b-256 a0670ebf431887171df059bdba4779fb247b055a95fb4fb25165573ac2ef2911

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page