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 snippets 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, numpy, matplotlib, seaborn 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
โ โโโ color_palette_utils.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
โโโ 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 usingPipelineorColumnTransformer.hyperparameter_tuner.py: WrapsGridSearchCVorRandomizedSearchCVwith easy setup and evaluation.
๐น 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.
๐ ๏ธ Usage
Copy-Paste ๐ฆ
๐ 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file utils_axn_2237-0.0.7.tar.gz.
File metadata
- Download URL: utils_axn_2237-0.0.7.tar.gz
- Upload date:
- Size: 13.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f395309a5dc63fc3334b30ecf5387c1606e4f256857c12432652e307bc86dea3
|
|
| MD5 |
3c52c3e0ffef0e4342d3fe013becad16
|
|
| BLAKE2b-256 |
b29a6545bde0093177cf2f08d9a3ddb55f53cd2bec2cb8400bfb3074d792b69e
|
File details
Details for the file utils_axn_2237-0.0.7-py3-none-any.whl.
File metadata
- Download URL: utils_axn_2237-0.0.7-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b8ccf81d18ebce26afc99fa76c709e7fe0df3914825c2783ee69f16a0df3544
|
|
| MD5 |
cc01b76c34b458408a3c1b1e57cd1798
|
|
| BLAKE2b-256 |
8763062475ccd0a1187074ce0cc8cae1e65db9b01b81785e65849e7c0f38c403
|