Metadata-Version: 2.4
Name: bussines_manager
Version: 0.1.1
Summary: Library to analyze the sales of a small bussines
Author-email: Miguel <miguel.saezdeviteri@alumni.mondragon.edu>, Xabier <xabier.crespo@alumni.mondragon.edu>
License-Expression: MIT
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pandas
Requires-Dist: numpy
Dynamic: license-file

# Bussines Manager

**Bussines Manager** is a Python library designed to analyze sales data from small businesses, such as bakeries, cafés, and retail stores.

It provides tools for analyzing products, revenue, customer purchasing habits, and peak sales days and hours.

## 1. Requirements

- Python 3.10 or higher.
- pandas.
- numpy.

These dependencies are specified in the `pyproject.toml` file.

## 2. Installation

Once the library has been published on PyPI, it can be installed using:

```bash
pip install bussines-manager
```

The library can be imported into Python using:

```python
import bussines_manager as bm
```

## 3. CSV File Format

The library works with CSV files containing the following columns:

| Column | Description |
|---|---|
| Fecha | Sale date (YYYY-MM-DD) |
| ID_Ticket | Unique numeric ticket identifier |
| Producto | Name of the product |
| Categoria | Product category |
| Precio | Unit price of the product |
| Cantidad | Number of units sold |
| Hora | Time of sale (HH:MM) |

The `Hora` column is optional for most analyses but required for the peak hours analysis.

### Example CSV

```csv
Fecha,ID_Ticket,Producto,Categoria,Precio,Cantidad,Hora
2026-11-01,1,Pan,Panaderia,1.50,2,09:30
2026-11-01,1,Cafe,Bebidas,1.80,1,09:30
2026-11-01,2,Croissant,Bolleria,2.00,3,10:15
2026-11-01,2,Cafe,Bebidas,1.80,2,10:15
2026-11-02,3,Pan,Panaderia,1.50,4,11:00
```

## 4. Available Functions

### 4.1. validar_ventas()

Validates the CSV file by checking its structure, required columns, and data types.

If the file contains invalid data, the function raises an error and stops the analysis.

### 4.2. productos_estrella()

Identifies the best-selling products based on total revenue and units sold.

Returns two tables ranked from highest to lowest.

### 4.3. productos_menos_vendidos()

Identifies the least-selling products based on total revenue and units sold.

Returns two tables ranked from lowest to highest.

### 4.4. analisis_cesta()

Analyzes which products are frequently purchased together in the same transaction.

Calculates the number of occurrences and the percentage of transactions containing each product pair.

Returns up to five most frequent and five least frequent observed combinations.

### 4.5. dias_pico()

Identifies the days of the week with the highest average revenue.

### 4.6. ticket_medio()

Calculates the average amount spent per transaction.

### 4.7. cantidad_media_producto()

Calculates the average quantity purchased of a specific product per transaction containing that product.

### 4.8. horas_pico()

Identifies the hours of the day with the highest sales revenue and number of units sold.

### 4.9. ventas_por_categoria()

Groups products by category and calculates total revenue and units sold for each category.

### 4.10. tamano_medio_cesta()

Calculates the average number of units and distinct products purchased per transaction.

## 5. Usage Examples

First, import the library:

```python
import bussines_manager as bm
```

### Best-Selling Products

```python
revenue, units = bm.productos_estrella("ventas.csv")

print(revenue)
print(units)
```

### Least-Selling Products

```python
revenue, units = bm.productos_menos_vendidos("ventas.csv")

print(revenue)
print(units)
```

### Market Basket Analysis

```python
basket = bm.analisis_cesta("ventas.csv")

print(basket)
```

### Peak Sales Days

```python
days = bm.dias_pico("ventas.csv")

print(days)
```

### Average Transaction Value

```python
average = bm.ticket_medio("ventas.csv")

print("Average transaction value:", average)
```

### Average Product Quantity

```python
average = bm.cantidad_media_producto("ventas.csv", "Pan")

print("Average quantity:", average)
```

### Peak Sales Hours

```python
hours = bm.horas_pico("ventas.csv")

print(hours)
```

### Sales by Category

```python
categories = bm.ventas_por_categoria("ventas.csv")

print(categories)
```

### Average Basket Size

```python
units, products = bm.tamano_medio_cesta("ventas.csv")

print("Average units:", units)
print("Average distinct products:", products)
```

## 6. Data Validation

All analysis functions validate the CSV file before processing the data.

If the file contains missing columns, incorrect data types, invalid dates, or negative values where positive values are required, the library raises an error indicating the problem.

When the data is valid, the analysis continues without displaying unnecessary validation messages.

## 7. Authors

Developed by Miguel and Xabier.

## 8. License

This project is distributed under the MIT License. See the `LICENSE` file for more information.
