From 476e4574c8b0d0cf118e556f4b97be07143d2482 Mon Sep 17 00:00:00 2001 From: Priyansh Date: Sat, 22 Jan 2022 23:21:34 -0500 Subject: docs: add find() function --- README.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/README.md b/README.md index 94a18d6..b39b908 100644 --- a/README.md +++ b/README.md @@ -248,6 +248,29 @@ const headers = [...]; const frame = new Frame().header(headers).fromCSV(csvPath); ``` +### `find()` ![](https://img.shields.io/badge/chainable-green.svg?style=plastic) + +The `find()` method is used to find the rows that match the given condition. It takes a string or a number as an argument which is needed to be found in the frame. Optionally, it also takes an `options` object as as the second argument. + +The valid options are defined below: + + - `row`: The row index to seach in. Can also be an array of row indexes. + - `column`: The column name or index to search in. Can also be an array of column names or indexes. + - `strict`: If `true`, the search will be performed on the exact value. If `false`, the search will be performed on the value as a substring. Default is `false`. + +> **Hint**: You can also combine the `range()` helper method to pass a range of rows or columns. + +```js +// find all the rows with value 'John' in column 'Name' +const row = frame.find('John', {column: 'Name'}); + +// find all the rows with value 'John' in columns 0, 1 and 2. Perform a strict search +const row = frame.find('John', {column: [0, 1, 2], strict: true}); + +// find all the rows with value 'John' in columns 0, 1 and 2 and rows 3, 4 and 5. Perform a non-strict search +const row = frame.find('John', {column: [0, 1, 2], row: [3, 4, 5], strict: false}); +``` + ### `head()` ![](https://img.shields.io/badge/not%20chainable-red.svg?style=plastic) -- cgit v1.2.3