# sample-datatable

## Description

<mark style="color:purple;">`sample-datatable`</mark> *adaptor samples rows in a datatable.*

Sampling method provided are `first`, `random` or `last`, it will default to `first` if unspecified.

## Inputs

**`data`**\
Type: `datatable`\
Required: Yes\
The datatable to be sampled.

**`sampling method`**\
Type: `text`\
Required: No\
The sampling method to be used. Valid values are `first`, `random`, or `last`. If unspecified, defaults to `first`

**`sample size`**\
Type: `text`\
Required: No\
The number of rows to be included in the sample. If unspecified, defaults to `100`

## Outputs

**`sample data`**\
Type: `datatable`\
A datatable with the sampled rows.

## Examples

### Example 1: Default behaviour.

#### Inputs:

`data:`

| id        | country | number |
| --------- | ------- | ------ |
| Bovine    | GB      | 1      |
| Gibbon    | TR      | 1      |
| Orangutan | US      | 0      |
| Gorilla   | IND     | -2     |
| Human     | IND     | 0x     |
| Mouse     | IND     |        |

`sampling method:` *null (empty)*

`sample size:` *null (empty)*

#### Outputs:

`data`:

| id        | country | number |
| --------- | ------- | ------ |
| Bovine    | GB      | 1      |
| Gibbon    | TR      | 1      |
| Orangutan | US      | 0      |
| Gorilla   | IND     | -2     |
| Human     | IND     | 0x     |
| Mouse     | IND     |        |

-> Sampled datatable with default sample size `100`.

### Example 2: Sample datatable with specified sampling method.

#### Inputs:

`data:`

| id        | country | number |
| --------- | ------- | ------ |
| Bovine    | GB      | 1      |
| Gibbon    | TR      | 1      |
| Orangutan | US      | 0      |
| Gorilla   | IND     | -2     |
| Human     | IND     | 0x     |
| Mouse     | IND     |        |

`sampling method:` last

`sample size:` 3

#### Outputs:

`data`:

| id      | country | number |
| ------- | ------- | ------ |
| Gorilla | IND     | -2     |
| Human   | IND     | 0x     |
| Mouse   | IND     |        |

-> Sampled datatable with sample size `3` and sampling method `last`.

## Use case

* Create smaller datasets for testing downsteam applications before using a large dataset.


---

# 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://cgps.gitbook.io/data-flo/reference-guide/sample-datatable.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.
