red_amber 0.4.2 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/.devcontainer/Dockerfile +75 -0
  3. data/.devcontainer/devcontainer.json +38 -0
  4. data/.devcontainer/onCreateCommand.sh +22 -0
  5. data/.rubocop.yml +11 -5
  6. data/CHANGELOG.md +141 -17
  7. data/Gemfile +5 -6
  8. data/README.ja.md +271 -0
  9. data/README.md +52 -31
  10. data/Rakefile +55 -0
  11. data/benchmark/group.yml +12 -5
  12. data/doc/Dev_Containers.ja.md +290 -0
  13. data/doc/Dev_Containers.md +292 -0
  14. data/doc/qmd/examples_of_red_amber.qmd +4596 -0
  15. data/doc/qmd/red-amber.qmd +90 -0
  16. data/docker/Dockerfile +2 -2
  17. data/docker/Gemfile +8 -3
  18. data/docker/docker-compose.yml +1 -1
  19. data/docker/readme.md +5 -5
  20. data/lib/red_amber/data_frame.rb +78 -4
  21. data/lib/red_amber/data_frame_combinable.rb +147 -119
  22. data/lib/red_amber/data_frame_displayable.rb +7 -6
  23. data/lib/red_amber/data_frame_loadsave.rb +1 -1
  24. data/lib/red_amber/data_frame_selectable.rb +51 -2
  25. data/lib/red_amber/data_frame_variable_operation.rb +6 -6
  26. data/lib/red_amber/group.rb +476 -127
  27. data/lib/red_amber/helper.rb +26 -0
  28. data/lib/red_amber/subframes.rb +18 -11
  29. data/lib/red_amber/vector.rb +45 -25
  30. data/lib/red_amber/vector_aggregation.rb +26 -0
  31. data/lib/red_amber/vector_selectable.rb +124 -40
  32. data/lib/red_amber/vector_string_function.rb +279 -0
  33. data/lib/red_amber/vector_unary_element_wise.rb +4 -0
  34. data/lib/red_amber/vector_updatable.rb +28 -0
  35. data/lib/red_amber/version.rb +1 -1
  36. data/lib/red_amber.rb +2 -1
  37. data/red_amber.gemspec +3 -3
  38. metadata +19 -14
  39. data/docker/Gemfile.lock +0 -80
  40. data/docker/example +0 -74
  41. data/docker/notebook/examples_of_red_amber.ipynb +0 -8562
  42. data/docker/notebook/red-amber.ipynb +0 -188
data/README.ja.md ADDED
@@ -0,0 +1,271 @@
1
+ # RedAmber
2
+
3
+ [![Gem Version](https://img.shields.io/gem/v/red_amber?color=brightgreen)](https://rubygems.org/gems/red_amber)
4
+ [![CI](https://github.com/heronshoes/red_amber/actions/workflows/ci.yml/badge.svg)](https://github.com/red-data-tools/red_amber/actions/workflows/ci.yml)
5
+ [![Maintainability](https://api.codeclimate.com/v1/badges/b8a745047045d2f49daa/maintainability)](https://codeclimate.com/github/heronshoes/red_amber/maintainability)
6
+ [![Test coverage](https://api.codeclimate.com/v1/badges/b8a745047045d2f49daa/test_coverage)](https://codeclimate.com/github/heronshoes/red_amber/test_coverage)
7
+ [![Doc](https://img.shields.io/badge/docs-latest-blue)](https://red-data-tools.github.io/red_amber/)
8
+ [![Discussions](https://img.shields.io/github/discussions/heronshoes/red_amber)](https://github.com/red-data-tools/red_amber/discussions)
9
+
10
+ Rubyistのためのデータフレームライブラリ.
11
+
12
+ - Powered by [Red Arrow](https://github.com/apache/arrow/tree/master/ruby/red-arrow)
13
+ [![Red Data Tools Chat (ja)](https://badges.gitter.im/red-data-tools/en.svg)](https://app.element.io/#/room/#red-data-tools_ja:gitter.im) [![Gem Version](https://img.shields.io/gem/v/red-arrow?color=brightgreen)](https://rubygems.org/gems/red-arrow)
14
+ - Inspired by the dataframe library [Rover-df](https://github.com/ankane/rover)
15
+
16
+ [README in English](README.md)
17
+
18
+ ![screenshot from jupyterlab](https://raw.githubusercontent.com/red-data-tools/red_amber/main/doc/image/screenshot.png)
19
+
20
+ ## 概要
21
+ * RedAmberはRubyで書かれたデータフレームライブラリです。[Apache Arrow](https://arrow.apache.org/)の列指向データフォーマットを扱うことができます。
22
+ * Rubyらしいブロックやコレクションを使って、Rubyらしい書き方でデータフレームの操作ができることを目指しています。
23
+ * このリポジトリは[開発コンテナ(Dev Container)](https://containers.dev/)をサポートしているので、RedAmberの操作が容易に[試せます](doc/Dev_Containers.ja.md)。
24
+ * [使用例が豊富なドキュメント](https://red-data-tools.github.io/red_amber/)と、127項目の主な操作例を記載したJupyter Notebookドキュメントがあります。
25
+
26
+ ## 必要な環境
27
+ ### Ruby
28
+ - Ruby 3.0 以上.
29
+
30
+ ### ライブラリ
31
+ ```ruby
32
+ gem 'red-arrow', '~> 12.0.0' # お使いの環境に合わせた Apache Arrow が必要です
33
+                  # 下記のインストールを参照してください
34
+ gem 'red-arrow-numo-narray' # 必要に応じて。Numo::NArray との連携またはランダムサンプリングが必要な場合。
35
+ gem 'red-parquet', '~> 12.0.0' # 必要に応じて。Parquet の入出力が必要な場合。
36
+ gem 'red-datasets-arrow' # 必要に応じて。Red Datasets を利用する場合。
37
+ gem 'red-arrow-activerecord' # 必要に応じて。Active Record とのデータ交換が必要な場合。
38
+ gem 'rover-df', # 必要に応じて。Rover::DataFrame に対する入出力が必要な場合。
39
+ ```
40
+
41
+ ## インストール
42
+
43
+ RedAmberをインストールする前に、下記のライブラリのインストールが必要です。
44
+
45
+ - Apache Arrow (~> 12.0.0)
46
+ - Apache Arrow GLib (~> 12.0.0)
47
+ - Apache Parquet GLib (~> 12.0.0) # Parquetの入出力が必要な場合。
48
+
49
+ 環境ごとの詳しいインストール方法は、 [Apache Arrow install document](https://arrow.apache.org/install/) を参照してください。
50
+
51
+ - Ubuntuの場合の最低限必要なインストール例:
52
+
53
+ ```
54
+ sudo apt update
55
+ sudo apt install -y -V ca-certificates lsb-release wget
56
+ wget https://apache.jfrog.io/artifactory/arrow/$(lsb_release --id --short | tr 'A-Z' 'a-z')/apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb
57
+ sudo apt install -y -V ./apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb
58
+ sudo apt update
59
+ sudo apt install -y -V libarrow-dev libarrow-glib-dev
60
+ ```
61
+
62
+ - Fedora 39 (Rawhide)の場合:
63
+
64
+ ```
65
+ sudo dnf update
66
+ sudo dnf -y install gcc-c++ libarrow-devel libarrow-glib-devel ruby-devel
67
+ ```
68
+
69
+ - macOS の場合は、Homebrewを使用する:
70
+
71
+ ```
72
+ brew install apache-arrow apache-arrow-glib
73
+ ```
74
+
75
+ Apache Arrowがインストールできたら、下記の行をGemfileに追加してください:
76
+
77
+ ```ruby
78
+ gem 'red-arrow', '~> 12.0.0'
79
+ gem 'red_amber'
80
+ gem 'red-arrow-numo-narray' # 必要に応じて。Numo::NArray との連携またはランダムサンプリングが必要な場合。
81
+ gem 'red-parquet', '~> 12.0.0' # 必要に応じて。Parquetの入出力が必要な場合。
82
+ gem 'red-datasets-arrow' # 必要に応じて。Red Datasets を利用する場合。
83
+ gem 'red-arrow-activerecord' # 必要に応じて。Active Record とのデータ交換が必要な場合。
84
+ gem 'rover-df', # 必要に応じて。Rover::DataFrameに対する入出力が必要な場合。
85
+ ```
86
+
87
+ `bundle install`とするか、または `gem install red_amber`としてインストールしてください。
88
+
89
+ ## Development Containersによる開発環境
90
+
91
+ このリポジトリは [開発コンテナ(Dev Container)](https://containers.dev/)をサポートしています。
92
+ これを使うと、ローカルの環境を変更することなく、RedAmberに必要なツール一式を含んだ環境を準備することができます。この環境には、Ruby、Apache Arrow、RedAmberのソースツリー、GitHub CI、サンプルデータセット、IRubyカーネルを含んだJupyter Labなどが含まれています。
93
+
94
+ RedAmber用のDev Containerは、`.devcontainer` ディレクトリに必要な設定が書かれています。
95
+ 使用例は、[開発コンテナ(Development Containers)の利用](doc/Dev_Containers.ja.md)をご参照ください。
96
+
97
+ ## Docker イメージと Jupyter Notebook
98
+
99
+ (注:将来削除される可能性があります。上記のDev Containerをご活用ください。)
100
+
101
+ このリポジトリの`docker` フォルダーから Docker コンテナ環境を生成できます。リポジトリをクローンしてから、dockerフォルダーにある [readme](docker/readme.md) を参照してください。その環境では `docker/notebook` フォルダーにある Jupyter Notebookイメージを試用できます。
102
+
103
+ このREADMEの内容をネットワーク上のJupyter Notebookでインタラクティブに試用することも出来ます。 [Binder](https://mybinder.org/v2/gh/heronshoes/docker-stacks/RedAmber-binder?filepath=red-amber.ipynb).
104
+ [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/heronshoes/docker-stacks/RedAmber-binder?filepath=red-amber.ipynb)
105
+
106
+ Jupyter Notebookの環境を含めた他の多くのデータ処理用のライブラリーとともにRedAmberもパッケージングされたDocker Imageとして、[RubyData Docker Stacks](https://github.com/RubyData/docker-stacks) が利用できます(Thanks to Kenta Murata).
107
+
108
+ ## 他のデータフレームライブラリとの比較表
109
+
110
+ RedAmberの基本的な機能をPython
111
+ [pandas](https://pandas.pydata.org/) や
112
+ R [Tidyverse](https://www.tidyverse.org/) や
113
+ Julia [Dataframes](https://dataframes.juliadata.org/stable/) と比較した表は [DataFrame_Comparison.md](doc/DataFrame_Comparison.md) にあります(Thanks to Benson Muite).
114
+
115
+ ## `RedAmber`のデータフレーム
116
+
117
+ クラス `RedAmber::DataFrame` は2次元のデータの集まりを表現します。
118
+ その実体は Red Arrowの Tableオブジェクトです。
119
+
120
+ ![dataframe model of RedAmber](https://raw.githubusercontent.com/red-data-tools/red_amber/main/doc/image/dataframe_model.png)
121
+
122
+ それではライブラリをロードしていくつかの例を試してみましょう。
123
+
124
+ ```ruby
125
+ require 'red_amber' # require 'red-amber' でもOKです.
126
+ include RedAmber
127
+ ```
128
+
129
+ ### 例: diamonds データセット
130
+
131
+ もしまだであれば、Red DatasetsのArrow拡張を`
132
+ gem install red-datasets-arrow
133
+ `
134
+ としてインストールしてから次を実行してください。
135
+
136
+ ```ruby
137
+ require 'datasets-arrow' # サンプルデータのロードのため
138
+
139
+ dataset = Datasets::Diamonds.new
140
+ diamonds = DataFrame.new(dataset) # v0.2.3以前では, `dataset.to_arrow`とする必要があります。
141
+
142
+ # =>
143
+ #<RedAmber::DataFrame : 53940 x 10 Vectors, 0x000000000000f668>
144
+ carat cut color clarity depth table price x ... z
145
+ <double> <string> <string> <string> <double> <double> <uint16> <double> ... <double>
146
+ 0 0.23 Ideal E SI2 61.5 55.0 326 3.95 ... 2.43
147
+ 1 0.21 Premium E SI1 59.8 61.0 326 3.89 ... 2.31
148
+ 2 0.23 Good E VS1 56.9 65.0 327 4.05 ... 2.31
149
+ 3 0.29 Premium I VS2 62.4 58.0 334 4.2 ... 2.63
150
+ 4 0.31 Good J SI2 63.3 58.0 335 4.34 ... 2.75
151
+ : : : : : : : : : ... :
152
+ 53937 0.7 Very Good D SI1 62.8 60.0 2757 5.66 ... 3.56
153
+ 53938 0.86 Premium H SI2 61.0 58.0 2757 6.15 ... 3.74
154
+ 53939 0.75 Ideal D SI2 62.2 55.0 2757 5.83 ... 3.64
155
+ ```
156
+
157
+ 例えば、1カラット以下のレコードに対し、cut毎の平均のpriceを求めるには次のようにします。
158
+
159
+ ```ruby
160
+ df = diamonds
161
+ .slice { carat > 1 } # #sliceの代わりに#filterでも可
162
+ .group(:cut)
163
+ .mean(:price) # ここで:priceを指定する場合はgroupの前のpickは不要
164
+ .sort('-mean(price)')
165
+
166
+ # =>
167
+ #<RedAmber::DataFrame : 5 x 2 Vectors, 0x000000000000f67c>
168
+ cut mean(price)
169
+ <string> <double>
170
+ 0 Ideal 8674.23
171
+ 1 Premium 8487.25
172
+ 2 Very Good 8340.55
173
+ 3 Good 7753.6
174
+ 4 Fair 7177.86
175
+ ```
176
+
177
+ Arrowのデータはイミュータブルなので、これらのメソッドは新しいオブジェクトを返します。
178
+
179
+ 次の例は、列をリネームしてから新しい列に簡単な計算の結果を格納します。
180
+
181
+ ```ruby
182
+ usdjpy = 110.0 # 今よりずっと円高の頃
183
+
184
+ df.rename('mean(price)': :mean_price_USD)
185
+ .assign(:mean_price_JPY) { mean_price_USD * usdjpy }
186
+
187
+ # =>
188
+ #<RedAmber::DataFrame : 5 x 3 Vectors, 0x000000000000f71c>
189
+ cut mean_price_USD mean_price_JPY
190
+ <string> <double> <double>
191
+ 0 Ideal 8674.23 954164.93
192
+ 1 Premium 8487.25 933597.34
193
+ 2 Very Good 8340.55 917460.37
194
+ 3 Good 7753.6 852896.11
195
+ 4 Fair 7177.86 789564.12
196
+ ```
197
+
198
+ ### 例: starwars データセット
199
+
200
+ 次の例は、CSVファイルをダウンロードして`starwars` データセットを読み込みます。その後簡単なデータのクリーニングを行います。
201
+
202
+ ```ruby
203
+ uri = URI('https://vincentarelbundock.github.io/Rdatasets/csv/dplyr/starwars.csv')
204
+
205
+ starwars = DataFrame.load(uri)
206
+
207
+ starwars
208
+ .drop(0) # 不要な列を取り除く
209
+ .remove { species == "NA" } # 不要な行を取り除く
210
+ .group(:species) { [count(:species), mean(:height, :mass)] }
211
+ .slice { count > 1 } # #filterでも可
212
+
213
+ # =>
214
+ #<RedAmber::DataFrame : 8 x 4 Vectors, 0x000000000000f848>
215
+ species count mean(height) mean(mass)
216
+ <string> <int64> <double> <double>
217
+ 0 Human 35 176.65 82.78
218
+ 1 Droid 6 131.2 69.75
219
+ 2 Wookiee 2 231.0 124.0
220
+ 3 Gungan 3 208.67 74.0
221
+ 4 Zabrak 2 173.0 80.0
222
+ 5 Twi'lek 2 179.0 55.0
223
+ 6 Mirialan 2 168.0 53.1
224
+ 7 Kaminoan 2 221.0 88.0
225
+ ```
226
+
227
+ より詳しいデータフレームの使用例については、[DataFrame.md](doc/DataFrame.md) をご参照ください。
228
+
229
+
230
+ ### 1次元のデータを保持する `Vector`
231
+
232
+ クラス`RedAmber::Vector` はデータフレームの中の列方向に格納された1次元のデータ列を保持します.
233
+
234
+ より詳しい使用例については [Vector.md](doc/Vector.md) をご参照ください。
235
+
236
+
237
+ ## Jupyter Notebook
238
+
239
+ このリポジトリでは [Quarto](https://quarto.org/) を使って、操作例を載せたJupyter Notebookのソースはqmd形式で保存し、gitの管理下に置いています。Notebookの生成は開発コンテナを使うと便利です。詳しくは[開発コンテナ(Development Containers)の利用](doc/Dev_Containers.ja.md)を利用して下さい。
240
+
241
+ ## 開発
242
+
243
+ Dev Containersを利用してコンテナ上に開発環境を作成する方法がお勧めです。[開発コンテナ(Development Containers)の利用例](doc/Dev_Containers.ja.md)を参考にしてください。
244
+
245
+ または、ローカル環境に必要なライブラリをインストールした上で、下記を実行するとテストが走ります。
246
+
247
+ ```shell
248
+ git clone https://github.com/red-data-tools/red_amber.git
249
+ cd red_amber
250
+ bundle install
251
+ bundle exec rake test
252
+ ```
253
+
254
+ RedAmberの開発では、`rake test` は必須ですが、`rake rubocop` をパスすることはコントリビュートの際に必須ではありません。このプロジェクトではコードの書き方の好みを尊重します。ただしマージの際に書き方を統一させていただくことがあります。
255
+
256
+ ## コミュニティ
257
+
258
+ このプロジェクトを支援して頂けると嬉しいです。支援の方法はいくつかあります。
259
+
260
+ - [discussions](https://github.com/heronshoes/red_amber/discussions)でお話ししましょう! [![Discussions](https://img.shields.io/github/discussions/heronshoes/red_amber)](https://github.com/red-data-tools/red_amber/discussions)
261
+ - Q and Aや使用方法、豆知識などを見流ことができます。
262
+ - 疑問に思っていることを質問できます。
263
+ - 新しいアイデアを共有する。アイデアはdiscussionからissueに昇格させて育てていくこともあります。漠然としたアイデアでもdiscussionから始めて大きくしていきましょう。
264
+ - [バグ報告や新しい機能の提案](https://github.com/red-data-tools/red_amber/issues)
265
+ - バグの修正や[プルリクエスト](https://github.com/red-data-tools/red_amber/pulls)
266
+ - ドキュメントを修正したり、不明確なところを直したり、新しく追加しましょう。
267
+ 皆さんのご参加をお待ちしています。
268
+
269
+ ## License
270
+
271
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/README.md CHANGED
@@ -4,39 +4,50 @@
4
4
  [![CI](https://github.com/heronshoes/red_amber/actions/workflows/ci.yml/badge.svg)](https://github.com/red-data-tools/red_amber/actions/workflows/ci.yml)
5
5
  [![Maintainability](https://api.codeclimate.com/v1/badges/b8a745047045d2f49daa/maintainability)](https://codeclimate.com/github/heronshoes/red_amber/maintainability)
6
6
  [![Test coverage](https://api.codeclimate.com/v1/badges/b8a745047045d2f49daa/test_coverage)](https://codeclimate.com/github/heronshoes/red_amber/test_coverage)
7
- [![Doc](https://img.shields.io/badge/docs-latest-blue)](https://heronshoes.github.io/red_amber/)
7
+ [![Doc](https://img.shields.io/badge/docs-latest-blue)](https://red-data-tools.github.io/red_amber/)
8
8
  [![Discussions](https://img.shields.io/github/discussions/heronshoes/red_amber)](https://github.com/red-data-tools/red_amber/discussions)
9
9
 
10
- A simple dataframe library for Ruby.
10
+ A dataframe library for Rubyists.
11
11
 
12
12
  - Powered by [Red Arrow](https://github.com/apache/arrow/tree/master/ruby/red-arrow)
13
- [![Gitter Chat](https://badges.gitter.im/red-data-tools/en.svg)](https://gitter.im/red-data-tools/en) [![Gem Version](https://img.shields.io/gem/v/red-arrow?color=brightgreen)](https://rubygems.org/gems/red-arrow)
13
+ [![Red Data Tools Chat (en)](https://badges.gitter.im/red-data-tools/en.svg)](https://app.element.io/#/room/#red-data-tools_en:gitter.im) [![Gem Version](https://img.shields.io/gem/v/red-arrow?color=brightgreen)](https://rubygems.org/gems/red-arrow)
14
14
  - Inspired by the dataframe library [Rover-df](https://github.com/ankane/rover)
15
15
 
16
+ [日本語のREADME](README.ja.md)
17
+
16
18
  ![screenshot from jupyterlab](https://raw.githubusercontent.com/red-data-tools/red_amber/main/doc/image/screenshot.png)
17
19
 
20
+ ## Overview
21
+ * RedAmber is a dataframe library written in ruby. It uses columnar memory format based on [Apache Arrow](https://arrow.apache.org/).
22
+ * Our goal is to manipulate data frames in a Ruby-like writing style using blocks and collections.
23
+ * You can easily try RedAmber with [Dev Container](https://containers.dev/). See [RedAmber Dev Container](doc/Dev_Containers.md).
24
+ * We have [rich document with many examples](https://red-data-tools.github.io/red_amber/) and Jupyter Notebook with 127 operation examples. See [RedAmber Dev Container](doc/Dev_Containers.md).
25
+
18
26
  ## Requirements
19
27
  ### Ruby
20
- Supported Ruby version is >= 3.0 (since RedAmber 0.3.0).
21
- - I decided to remove support for Ruby 2.7 without waiting for its EOL. See [Release note for v0.3.0](https://github.com/red-data-tools/red_amber/discussions/162) for details.
28
+ Supported Ruby version is >= 3.0.
22
29
 
23
- ### Libraries
30
+ ### Required libraries
24
31
  ```ruby
25
- gem 'red-arrow', '~> 11.0.0' # Requires Apache Arrow (see installation below)
26
- gem 'red-parquet', '~> 11.0.0' # Optional, if you use IO from/to parquet
27
- gem 'rover-df', '~> 0.3.0' # Optional, if you use IO from/to Rover::DataFrame
32
+ gem 'red-arrow', '~> 12.0.0' # Requires Apache Arrow (see installation below).
33
+ gem 'red-arrow-numo-narray' # Optional, recommended if you use inputs from Numo::NArray,
34
+ # or use random sampling feature.
35
+ gem 'red-parquet', '~> 12.0.0' # Optional, if you use IO from/to parquet.
36
+ gem 'red-datasets-arrow' # Optional, if you use Red Datasets.
37
+ gem 'red-arrow-activerecord' # Optional, if you use Active Record.
38
+ gem 'rover-df', # Optional, if you use IO from/to Rover::DataFrame.
28
39
  ```
29
40
 
30
41
  ## Installation
31
42
 
32
43
  Install requirements before you install RedAmber.
33
44
 
34
- - Apache Arrow (~> 11.0.0)
35
- - Apache Arrow GLib (~> 11.0.0)
36
- - Apache Parquet GLib (~> 11.0.0) # If you use IO from/to parquet
45
+ - Apache Arrow (~> 12.0.0)
46
+ - Apache Arrow GLib (~> 12.0.0)
47
+ - Apache Parquet GLib (~> 12.0.0) # If you use IO from/to parquet
37
48
 
38
49
  See [Apache Arrow install document](https://arrow.apache.org/install/).
39
-
50
+
40
51
  - Minimum installation example for the latest Ubuntu:
41
52
 
42
53
  ```
@@ -45,11 +56,10 @@ See [Apache Arrow install document](https://arrow.apache.org/install/).
45
56
  wget https://apache.jfrog.io/artifactory/arrow/$(lsb_release --id --short | tr 'A-Z' 'a-z')/apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb
46
57
  sudo apt install -y -V ./apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb
47
58
  sudo apt update
48
- sudo apt install -y -V libarrow-dev
49
- sudo apt install -y -V libarrow-glib-dev
59
+ sudo apt install -y -V libarrow-dev libarrow-glib-dev
50
60
  ```
51
61
 
52
- - On Fedora 38 (Rawhide):
62
+ - On Fedora 39 (Rawhide):
53
63
 
54
64
  ```
55
65
  sudo dnf update
@@ -59,35 +69,45 @@ See [Apache Arrow install document](https://arrow.apache.org/install/).
59
69
  - On macOS, using Homebrew:
60
70
 
61
71
  ```
62
- brew install apache-arrow
63
- brew install apache-arrow-glib
72
+ brew install apache-arrow apache-arrow-glib
64
73
  ```
65
74
 
66
75
  If you prepared Apache Arrow, add these lines to your Gemfile:
67
76
 
68
77
  ```ruby
69
- gem 'red-arrow', '~> 11.0.0'
78
+ gem 'red-arrow', '~> 12.0.0'
70
79
  gem 'red_amber'
71
- gem 'red-parquet', '~> 11.0.0' # Optional, if you use IO from/to parquet
72
- gem 'rover-df', '~> 0.3.0' # Optional, if you use IO from/to Rover::DataFrame
73
- gem 'red-datasets-arrow' # Optional, recommended if you use Red Datasets
74
80
  gem 'red-arrow-numo-narray' # Optional, recommended if you use inputs from Numo::NArray
81
+ # or use random sampling feature.
82
+ gem 'red-parquet', '~> 12.0.0' # Optional, if you use IO from/to parquet
83
+ gem 'red-datasets-arrow' # Optional, recommended if you use Red Datasets
84
+ gem 'red-arrow-activerecord' # Optional, if you use Active Record
85
+ gem 'rover-df', # Optional, if you use IO from/to Rover::DataFrame.
75
86
  ```
76
87
 
77
88
  And then execute `bundle install` or install them yourself such as `gem install red_amber`.
78
89
 
90
+ ## Development Containers
91
+
92
+ This repository supports [Dev Containers](https://containers.dev/). You can create a container as a full-featured development environment for RedAmber. The environment includes Ruby, Apache Arrow, RedAmber with source tree, GitHub CLI, sample datasets and Jupyter Lab with IRuby kernel. And you don't need to worry about the change of your local environment.
93
+
94
+ `.devcontainer` directory in this repository includes settings of Dev Container for RedAmber.
95
+ Please refer [How to use Dev Containers in RedAmber](doc/Dev_Containers.md) to use it.
96
+
79
97
  ## Docker image and Jupyter Notebook
80
98
 
81
- Docker image is available from docker folder. See [readme](docker/readme.md) for instruction. Integrated Jypyter notebook is in docker/notebook folder.
99
+ (Notice: This feature may be removed in the future. Try Dev Container above.)
100
+
101
+ Docker image is available from `docker` folder. See [readme](docker/readme.md) for instruction. Integrated Jypyter notebook is in docker/notebook folder.
82
102
 
83
- You can try the contents of this README interactively by [Binder](https://mybinder.org/v2/gh/heronshoes/docker-stacks/RedAmber-binder?filepath=red-amber.ipynb).
103
+ You can try the contents of this README interactively by [Binder](https://mybinder.org/v2/gh/heronshoes/docker-stacks/RedAmber-binder?filepath=red-amber.ipynb).
84
104
  [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/heronshoes/docker-stacks/RedAmber-binder?filepath=red-amber.ipynb)
85
105
 
86
106
  [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 Kenta Murata).
87
107
 
88
108
  ## Comparison of DataFrames
89
109
 
90
- Comparison of basic features of RedAmber with Python
110
+ Comparison of basic features of RedAmber with Python
91
111
  [pandas](https://pandas.pydata.org/),
92
112
  R [Tidyverse](https://www.tidyverse.org/) and
93
113
  Julia [Dataframes](https://dataframes.juliadata.org/stable/) is in [DataFrame_Comparison.md](doc/DataFrame_Comparison.md) (Thanks to Benson Muite).
@@ -95,7 +115,7 @@ Julia [Dataframes](https://dataframes.juliadata.org/stable/) is in [DataFrame_Co
95
115
  ## Data frame in `RedAmber`
96
116
 
97
117
  Class `RedAmber::DataFrame` represents a set of data in 2D-shape.
98
- Its entity is a Red Arrow's Table object.
118
+ Its entity is a Red Arrow's Table object.
99
119
 
100
120
  ![dataframe model of RedAmber](https://raw.githubusercontent.com/red-data-tools/red_amber/main/doc/image/dataframe_model.png)
101
121
 
@@ -214,14 +234,13 @@ See [Vector.md](doc/Vector.md) for details.
214
234
 
215
235
  ## Jupyter notebook
216
236
 
217
- [Examples of Red Amber](https://github.com/heronshoes/docker-stacks/blob/RedAmber-binder/binder/examples_of_red_amber.ipynb)
218
- ([raw file](https://raw.githubusercontent.com/heronshoes/docker-stacks/RedAmber-binder/binder/examples_of_red_amber.ipynb)) shows more examples in jupyter notebook.
237
+ We are managing the source of Jupyter Notebook in qmd format by Quarto. You can easily create Notebooks and try it with Jupyter Lab in [Dev Container](doc/Dev_Containers.md).
219
238
 
220
- You can try this notebook on [Binder](https://mybinder.org/v2/gh/heronshoes/docker-stacks/RedAmber-binder?filepath=examples_of_red_amber.ipynb).
221
- [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/heronshoes/docker-stacks/RedAmber-binder?filepath=examples_of_red_amber.ipynb)
239
+ ## Development
222
240
 
241
+ The recommended way to develop RedAmber is to use Dev Container. Please refer [How to use Dev Containers in RedAmber](doc/Dev_Containers.md) to use it.
223
242
 
224
- ## Development
243
+ Otherwise run below commands after install required libraries in your local system.
225
244
 
226
245
  ```shell
227
246
  git clone https://github.com/red-data-tools/red_amber.git
@@ -230,6 +249,8 @@ bundle install
230
249
  bundle exec rake test
231
250
  ```
232
251
 
252
+ We need to pass `rake test` in development of RedAmber, but not require to pass `rake rubocop` when you make a contribution. In this project we respect your preferences in code style. However, we may unify the style during merging.
253
+
233
254
  ## Community
234
255
 
235
256
  I will appreciate if you could help to improve this project. Here are a few ways you can help:
data/Rakefile CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'bundler/gem_tasks'
4
4
  require 'rake/testtask'
5
+ require 'rake/clean'
5
6
 
6
7
  Rake::TestTask.new(:test) do |t|
7
8
  t.libs << 'test'
@@ -15,3 +16,57 @@ require 'rubocop/rake_task'
15
16
  RuboCop::RakeTask.new
16
17
 
17
18
  task default: %i[test rubocop]
19
+
20
+ def install_gems_for_examples
21
+ sh 'cd bin; bundle install; cd -'
22
+ end
23
+
24
+ # Example
25
+ desc 'Start example environment'
26
+ task :example do
27
+ install_gems_for_examples
28
+ sh 'bundle exec --gemfile=bin/Gemfile bin/example'
29
+ end
30
+
31
+ # Quarto
32
+ namespace :quarto do
33
+ qmd_dir = 'doc/qmd'
34
+ notebook_dir = 'doc/notebook'
35
+
36
+ directory notebook_dir
37
+
38
+ qmd_files = FileList["#{qmd_dir}/*.qmd"]
39
+ qmd_files.exclude('~*.qmd')
40
+ notebooks = qmd_files.pathmap('%{qmd,notebook}p').ext('.ipynb')
41
+
42
+ qmd_files.zip(notebooks).each do |qmd, notebook|
43
+ file notebook => notebook_dir
44
+ file notebook => qmd do
45
+ sh "quarto convert #{qmd} -o #{notebook}"
46
+ end
47
+ end
48
+
49
+ desc 'Convert qmd to ipynb files'
50
+ task convert: notebooks
51
+ file notebooks => notebook_dir
52
+
53
+ desc 'test to execute notebooks'
54
+ task test: notebooks do
55
+ install_gems_for_examples
56
+ notebooks.each do |notebook|
57
+ quarto_options = '--execute-daemon-restart --execute'
58
+ sh "bundle exec --gemfile=bin/Gemfile quarto render #{notebook} #{quarto_options}"
59
+ end
60
+ end
61
+ end
62
+
63
+ desc 'Start jupyter lab'
64
+ task jupyter: 'quarto:convert' do
65
+ install_gems_for_examples
66
+
67
+ jupyter_options =
68
+ "--notebook-dir='doc/notebook' --NotebookApp.token=''"
69
+ sh "bundle exec --gemfile=bin/Gemfile jupyter lab #{jupyter_options}"
70
+ end
71
+
72
+ CLEAN << 'doc/notebook'
data/benchmark/group.yml CHANGED
@@ -1,18 +1,19 @@
1
1
  loop_count: 3
2
2
 
3
3
  contexts:
4
- - name: 0.2.2
5
- gems:
6
- red_amber: 0.2.2
7
4
  - name: 0.3.0
8
5
  gems:
9
6
  red_amber: 0.3.0
7
+ - name: 0.4.2
8
+ gems:
9
+ red_amber: 0.4.2
10
10
  - name: HEAD
11
11
  prelude: |
12
12
  $LOAD_PATH.unshift(File.expand_path('lib'))
13
13
 
14
14
  prelude: |
15
15
  require 'red_amber'
16
+ include RedAmber
16
17
  require 'datasets-arrow'
17
18
 
18
19
  ds = Datasets::Rdatasets.new('nycflights13', 'flights')
@@ -32,8 +33,14 @@ benchmark:
32
33
  'G03: sum arr_delay, mean distance by flight': |
33
34
  df.group(:flight) { [sum(:arr_delay), mean(:distance)] }
34
35
 
35
- 'G04: mean air_time, distance by flight': |
36
+ 'G04:filtersir_time, distance by flight': |
36
37
  df.group(:flight).mean(:air_time, :distance)
37
38
 
38
- 'G05: sum dep_delay, arr_delay by carrer': |
39
+ 'G75: sum dep_delay, arr_delay by carrer': |
39
40
  df.group(:carrier).sum(:dep_delay, :arr_delay)
41
+
42
+ 'G06: filters': |
43
+ Group.new(df, :dest).filters
44
+
45
+ 'G07: inspect': |
46
+ Group.new(df, :dest).inspect