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
endEdit
git clone [email protected]:sciruby/daru.git
cd daru
open lib/daru/dataframe.rb
Contribute
# Make a new branchgit checkout -b -your-name--update-docs-Daru--DataFrame-filter-for-pr
# Commit to gitgit add lib/daru/dataframe.rbgit commit -m "better docs for Daru::DataFrame#filter"
# Open pull requestgem 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!