# Market Basket

Analyze historical transaction contents to understand products that are frequently purchased together.

This approach uses a transactional table to aggregate each product purchased in a transaction, and then aggregates transactions together to look for common patterns.

## Parameters

| Name            | Type   | Description                                                                                | Is Optional |
| --------------- | ------ | ------------------------------------------------------------------------------------------ | ----------- |
| transaction\_id | column | Column identifying a unique event ID (i.e., transaction) for which to aggregate line items |             |
| sep             | value  | Text separator to use when aggregating the strings, i.e. ', ' or '\|'.                     |             |
| agg\_column     | column | Product ID or description to use when aggregating into transactions                        |             |

## Example

```python
sales = rasgo.get.dataset(id)

ds2 = sales.market_basket(transaction_id='SALESORDERNUMBER',
                agg_column='ENGLISHPRODUCTNAME',
                sep='|')
ds2.preview()
```

## Source Code

{% embed url="<https://github.com/rasgointelligence/RasgoTransforms/blob/main/rasgotransforms/rasgotransforms/transforms/market_basket/market_basket.sql>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.rasgoml.com/rasgo-docs/rasgo-0.1/all-transforms/market_basket.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
