Metadata-Version: 2.1
Name: abtestools
Version: 1.1.2
Summary: AB Test Framework for Python
License: MIT
Author: Pablo Minué
Requires-Python: >=3.10,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Dist: pandas (>=2.2.3,<3.0.0)
Requires-Dist: pydantic (>=2.9.2,<3.0.0)
Requires-Dist: rich (>=13.9.2,<14.0.0)
Requires-Dist: scipy (>=1.14.1,<2.0.0)
Requires-Dist: uuid (>=1.30,<2.0)
Description-Content-Type: text/markdown

[![Contributors][contributors-shield]][contributors-url]
[![Forks][forks-shield]][forks-url]
[![Stargazers][stars-shield]][stars-url]
[![Issues][issues-shield]][issues-url]
[![MIT License][license-shield]][license-url]
[![LinkedIn][linkedin-shield]][linkedin-url]

pyabtesting

    An awesome README template to jumpstart your projects!
    
    Explore the docs » (https://github.com/pablominue/pyabtesting)

    View Demo (https://github.com/pablominue/pyabtesting)
    ·
    Report Bug (https://github.com/pablominue/pyabtesting/issues/new?labels=bug&template=bug-report---.md)
    ·
    Request Feature (https://github.com/pablominue/pyabtesting/issues/new?labels=enhancement&template=feature-request---.md)

Table of Contents

-       About The Project

-       Getting Started

- Prerequisites
        
- Installation

- Usage

## About The Project

This library provides tools for AB Testing, very useful when working with marketing data

(back to top)

## Getting Started

### Prerequisites

To develop on this project, you will need to create a poetry environment with the needed dependencies
* install with Poetry
  ```sh
  poetry install
  ```

### Installation


1. 
   ```sh
   git clone https://github.com/pablominue/pyabtesting.git
   ```
   or
   ```sh
   pip install abtestools
   ```

3. Import main modules
   ```python
   from abtestools import audience, test
   ```


(back to top)

## Usage

```python
import datetime

import pandas as pd

from abtestools.audiences import Audience
from abtestools.campaign import Campaign
from abtestools.test import Metric

data = pd.read_csv("tests/cookie_cats.txt", delimiter=",")

audience = Audience(
    users=data["userid"], group_mapping=dict(zip(data["userid"], data["version"]))
)

campaign = Campaign(
    audience=audience,
    metrics=[
        Metric(name="retention_1", type="discrete"),
        Metric(name="retention_7", type="discrete"),
    ],
    date_range=[
        datetime.datetime.today() - datetime.timedelta(days=x) for x in range(10)
    ],
)


def extract_data(date, metric_column: str, convert_bool: bool = True) -> dict:
    # Logic for each date calculation should be added here
    if convert_bool:
        data[metric_column] = data[metric_column].astype(int)
    return dict(zip(data["userid"], data[metric_column]))


for res in campaign.backfill(
    metric=Metric(name="retention_1", type="discrete"),
    extract_data=extract_data,
    metric_column="retention_1",
):
    print(res)

```

 











[contributors-shield]:https://img.shields.io/github/contributors/pablominue/pyabtesting
[contributors-url]: https://github.com/pablominue/pyabtesting/graphs/contributors
[forks-shield]: https://img.shields.io/github/forks/pablominue/pyabtesting.svg?style=for-the-badge
[forks-url]: https://github.com/pablominue/pyabtesting/network/members
[stars-shield]: https://img.shields.io/github/stars/pablominue/pyabtesting.svg?style=for-the-badge
[stars-url]: https://github.com/pablominue/pyabtesting/stargazers
[issues-shield]: https://img.shields.io/github/issues/pablominue/pyabtesting.svg?style=for-the-badge
[issues-url]: https://github.com/pablominue/pyabtesting/issues
[license-shield]: https://img.shields.io/github/license/pablominue/pyabtesting.svg?style=for-the-badge
[license-url]: https://github.com/pablominue/pyabtesting/blob/master/LICENSE.txt
[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge&logo=linkedin&colorB=555
[linkedin-url]: https://linkedin.com/in/pablo-minue/
[product-screenshot]: images/screenshot.png
[Next.js]: https://img.shields.io/badge/next.js-000000?style=for-the-badge&logo=nextdotjs&logoColor=white
[Next-url]: https://nextjs.org/
[React.js]: https://img.shields.io/badge/React-20232A?style=for-the-badge&logo=react&logoColor=61DAFB
[python-url]: https://python.org/
[Vue.js]: https://img.shields.io/badge/Vue.js-35495E?style=for-the-badge&logo=vuedotjs&logoColor=4FC08D
[Vue-url]: https://vuejs.org/
[Angular.io]: https://img.shields.io/badge/Angular-DD0031?style=for-the-badge&logo=angular&logoColor=white
[Angular-url]: https://angular.io/
[Svelte.dev]: https://img.shields.io/badge/Svelte-4A4A55?style=for-the-badge&logo=svelte&logoColor=FF3E00
[Svelte-url]: https://svelte.dev/
[Laravel.com]: https://img.shields.io/badge/Laravel-FF2D20?style=for-the-badge&logo=laravel&logoColor=white
[Laravel-url]: https://laravel.com
[Bootstrap.com]: https://img.shields.io/badge/Bootstrap-563D7C?style=for-the-badge&logo=bootstrap&logoColor=white
[Bootstrap-url]: https://getbootstrap.com
[JQuery.com]: https://img.shields.io/badge/jQuery-0769AD?style=for-the-badge&logo=jquery&logoColor=white
[JQuery-url]: https://jquery.com 
