daru

https://github.com/sciruby/daru

Ruby

Data Analysis in RUby

Daru::DataFrame#filter

Retain vectors or rows if the block returns a truthy value.

== Description

For filtering out certain rows/vectors based on their values,
use the #filter method. By default it iterates over vectors and
keeps those vectors for which the block returns true. It accepts
an optional axis argument which lets you specify whether you want
to iterate over vectors or rows.

== Arguments

* +axis+ - The axis to map over. Can be :vector (or :column) or :row.
Default to :vector.

== Usage

  # Filter vectors

  df.filter do |vector|
    vector.type == :numeric and vector.median < 50
  end

  # Filter rows

  df.filter(:row) do |row|
    row[:a] + row[:d] < 100
  end

Source | Google | Stack overflow

Edit

git clone [email protected]:sciruby/daru.git

cd daru

open lib/daru/dataframe.rb

Contribute

# Make a new branch

git checkout -b -your-name--update-docs-Daru--DataFrame-filter-for-pr


# Commit to git

git add lib/daru/dataframe.rbgit commit -m "better docs for Daru::DataFrame#filter"


# Open pull request

gem install hub # on a mac you can `brew install hub`

hub fork

git push <your name> -your-name--update-docs-Daru--DataFrame-filter-for-pr

hub pull-request


# Celebrate!