dataFrame.rows — filter()

Description

The filter() method of the rows object keeps only the rows for which the specified function returns true.

Signature

dataFrame.rows.filter(function)
Scope
dataFrame
Family
rows
Returns
mutates

Argument

function (function)
A function used to determine whether each row should be kept.
  • The function receives a row object representing the current row. Column values can be accessed using column names:
    • row["name"]
    • row["age"]
  • The function must return a boolean value:
    • Keep the row: true
    • Remove the row: false

Example

// keeps rows where value in the column 'age' is greater than or equal to 18
dataFrame.rows.filter(function(row) {
  return row["age"] >= 18;
});