daru

https://github.com/sciruby/daru

Ruby

Data Analysis in RUby

Daru::Vector#rolling_fillna!

Rolling fillna
replace all Float::NAN and NIL values with the preceeding or following value

dv = Daru::Vector.new([1, 2, 1, 4, nil, Float::NAN, 3, nil, Float::NAN])

2.3.3 :068 > dv.rolling_fillna(:forward)
=> #<Daru::Vector(9)>
0   1
1   2
2   1
3   4
4   4
5   4
6   3
7   3
8   3

Source | Google | Stack overflow

Edit

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

cd daru

open lib/daru/vector.rb

Contribute

# Make a new branch

git checkout -b -your-name--update-docs-Daru--Vector-rolling_fillna--for-pr


# Commit to git

git add lib/daru/vector.rbgit commit -m "better docs for Daru::Vector#rolling_fillna!"


# 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--Vector-rolling_fillna--for-pr

hub pull-request


# Celebrate!