pandas-auto-prep 0.1.0
A pandas accessor that automates 80-90% of standard tabular data preprocessing tasks
License: MIT
Requires Python: >=3.8
Keywords: pandas, preprocessing, data-science, machine-learning, data-cleaning, feature-engineering, automation

# Pandas Auto Prep

[![PyPI version](https://badge.fury.io/py/pandas-auto-prep.svg)](https://pypi.org/project/pandas-auto-prep/)
[![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

A powerful pandas accessor that automates **80-90% of standard tabular data preprocessing tasks** with a single command.

## Installation

```bash
pip install pandas-auto-prep
```

## Quick Start

```python
import pandas as pd
import pandas_auto_prep  # This registers the .prep accessor

# Load your data
df = pd.read_csv("your_data.csv")

# Preprocess with one line!
X_train, X_test, y_train, y_test = df.prep.auto(target='target_column')
```

## Features

The `.prep.auto()` method performs the following preprocessing steps automatically:

| Step | Task | Details |
|------|------|---------|
| 1 | **Housekeeping** | Remove duplicates, constant columns, high-missing columns (>50%) |
| 2 | **Datetime Handling** | Extract Year, Month, Day, DayOfWeek from datetime columns |
| 3 | **Missing Value Imputation** | Median for numeric, Mode for categorical |
| 4 | **Skewness Handling** | Log(x+1) transformation for highly skewed columns |
| 5 | **Outlier Handling** | Winsorization (clip to 1st-99th percentiles) |
| 6 | **Categorical Encoding** | One-Hot for low cardinality, Label Encoding for high cardinality |
| 7 | **Scaling** | StandardScaler for all numeric features |
| 8 | **Train/Test Split** | Stratified split (configurable) |

## Parameters

```python
df.prep.auto(
    target='target_column',      # Target column name (optional)
    test_size=0.2,               # Test split ratio
    random_state=42,             # Random seed
    cardinality_thresh=10,       # One-Hot vs Label Encoding threshold
    missing_thresh=0.5,          # Drop columns with >50% missing
    skewness_thresh=1.0,         # Skewness threshold for log transform
    verbose=True                 # Print progress
)
```

## Usage Examples

### With Target (Supervised Learning)

```python
import pandas as pd
import pandas_auto_prep

df = pd.read_csv("customer_churn.csv")
X_train, X_test, y_train, y_test = df.prep.auto(target='churn')

# Ready for model training!
from sklearn.ensemble import RandomForestClassifier
model = RandomForestClassifier()
model.fit(X_train, y_train)
```

### Without Target (Data Cleaning Only)

```python
import pandas as pd
import pandas_auto_prep

df = pd.read_csv("messy_data.csv")
clean_df = df.prep.auto()  # Returns fully preprocessed DataFrame
```

### Access Fitted Objects

```python
# After running .prep.auto()
label_encoders = df.prep.get_label_encoders()  # For inverse transforms
scaler = df.prep.get_scaler()                   # Fitted StandardScaler
```

## Requirements

- Python >= 3.8
- pandas >= 1.3.0
- numpy >= 1.20.0
- scikit-learn >= 1.0.0

## License

MIT License - see [LICENSE](LICENSE) for details.

## Author

**Aarush Gupta**