README.md in red_amber-0.2.0 vs README.md in red_amber-0.2.1

- old
+ new

@@ -51,14 +51,25 @@ ```shell gem install red_amber ``` +## Docker image and Jupyter Notebook + +[RubyData Docker Stacks](https://github.com/RubyData/docker-stacks) is available as a ready-to-run Docker image containing Jupyter and useful data tools as well as RedAmber (Thanks to @mrkn). + +Also you can try the contents of this README interactively by [Binder](https://mybinder.org/v2/gh/RubyData/docker-stacks/master?filepath=red-amber.ipynb). +[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/RubyData/docker-stacks/master?filepath=red-amber.ipynb) + + + ## `RedAmber::DataFrame` -Represents a set of data in 2D-shape. The entity is a Red Arrow's Table object. +It represents a set of data in 2D-shape. The entity is a Red Arrow's Table object. +![dataframe model of RedAmber](doc/image/dataframe_model.png) + ```ruby require 'red_amber' # require 'red-amber' is also OK. require 'datasets-arrow' arrow = Datasets::Penguins.new.to_arrow @@ -77,22 +88,19 @@ 342 Gentoo Biscoe 50.4 15.7 222 ... 2009 343 Gentoo Biscoe 45.2 14.8 212 ... 2009 344 Gentoo Biscoe 49.9 16.1 213 ... 2009 ``` -### DataFrame model -![dataframe model of RedAmber](doc/image/dataframe_model.png) +For example, `DataFrame#pick` accepts keys as arguments and returns a sub DataFrame. -For example, `DataFrame#pick` accepts keys as an argument and returns a sub DataFrame. - ![pick method image](doc/image/dataframe/pick.png) ```ruby penguins.keys # => -[:species, - :island, +[:species, + :island, :bill_length_mm, :bill_depth_mm, :flipper_length_mm, :body_mass_g, :sex, @@ -100,29 +108,29 @@ df = penguins.pick(:species, :island, :body_mass_g) df # => -#<RedAmber::DataFrame : 344 x 3 Vectors, 0x000000000003cc1c> - species island body_mass_g - <string> <string> <uint16> - 1 Adelie Torgersen 3750 - 2 Adelie Torgersen 3800 - 3 Adelie Torgersen 3250 - 4 Adelie Torgersen (nil) - 5 Adelie Torgersen 3450 - : : : : -342 Gentoo Biscoe 5750 -343 Gentoo Biscoe 5200 +#<RedAmber::DataFrame : 344 x 3 Vectors, 0x000000000003cc1c> + species island body_mass_g + <string> <string> <uint16> + 1 Adelie Torgersen 3750 + 2 Adelie Torgersen 3800 + 3 Adelie Torgersen 3250 + 4 Adelie Torgersen (nil) + 5 Adelie Torgersen 3450 + : : : : +342 Gentoo Biscoe 5750 +343 Gentoo Biscoe 5200 344 Gentoo Biscoe 5400 ``` `DataFrame#drop` drops some columns to create a remainer DataFrame. ![drop method image](doc/image/dataframe/drop.png) -You can specify by keys or a boolean array (same size as n_keys). +You can specify by keys or a boolean array of same size as n_keys. ```ruby # Same as df.drop(:species, :island) df = df.drop(true, true, false) @@ -212,13 +220,19 @@ 244 Gentoo Biscoe 49.9 16.1 213 ... 2009 ``` DataFrame manipulating methods like `pick`, `drop`, `slice`, `remove`, `rename` and `assign` accept a block. -This example is usage of block to update a column. +Previous example is also OK with a block. ```ruby +penguins.remove { bill_length_mm < 40 } +``` + +Next example is an usage of block to update a column. + +```ruby df = RedAmber::DataFrame.new( integer: [0, 1, 2, 3, nil], float: [0.0, 1.1, 2.2, Float::NAN, nil], string: ['A', 'B', 'C', 'D', nil], boolean: [true, false, true, false, nil]) @@ -310,23 +324,23 @@ : : : : : : : : ... : 85 85 BB8 (nil) (nil) none none black ... Droid 86 86 Captain Phasma (nil) (nil) unknown unknown unknown ... NA 87 87 Padmé Amidala 165 45.0 brown light brown ... Human -grouped = starwars.group(:species) { [count(:species), mean(:height, :mass)] } -grouped.slice { v(:count) > 1 } +starwars.group(:species) { [count(:species), mean(:height, :mass)] } + .slice { count > 1 } # => #<RedAmber::DataFrame : 9 x 4 Vectors, 0x000000000006e848> species count mean(height) mean(mass) <string> <int64> <double> <double> 1 Human 35 176.6 82.8 2 Droid 6 131.2 69.8 3 Wookiee 2 231.0 124.0 4 Gungan 3 208.7 74.0 5 NA 4 181.3 48.0 -: : : : : +6 Zabrak 2 173.0 80.0 7 Twi'lek 2 179.0 55.0 8 Mirialan 2 168.0 53.1 9 Kaminoan 2 221.0 88.0 ``` @@ -372,10 +386,10 @@ See [Vector.md](doc/Vector.md) for details. ## Jupyter notebook -[61 Examples of Red Amber](doc/examples_of_red_amber.ipynb) shows more examples in jupyter notebook. +[71 Examples of Red Amber](doc/examples_of_red_amber.ipynb) shows more examples in jupyter notebook. ## Development ```shell git clone https://github.com/heronshoes/red_amber.git