{"id":23450776,"url":"https://github.com/red-data-tools/red_amber","last_synced_at":"2025-10-11T09:41:11.505Z","repository":{"id":36957309,"uuid":"481945999","full_name":"red-data-tools/red_amber","owner":"red-data-tools","description":"A dataframe library for Rubyists.","archived":false,"fork":false,"pushed_at":"2025-05-15T01:28:06.000Z","size":5599,"stargazers_count":72,"open_issues_count":6,"forks_count":13,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-10-03T05:25:56.254Z","etag":null,"topics":["apache-arrow","dataframe","dataframe-library","dataframes","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/red-data-tools.png","metadata":{"files":{"readme":"README.ja.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-04-15T12:06:47.000Z","updated_at":"2025-09-26T09:05:11.000Z","dependencies_parsed_at":"2025-01-07T02:43:04.678Z","dependency_job_id":"cf781965-82a9-4df6-b34a-16fe541d6920","html_url":"https://github.com/red-data-tools/red_amber","commit_stats":{"total_commits":694,"total_committers":8,"mean_commits":86.75,"dds":0.05907780979827093,"last_synced_commit":"93186f32c3524f0d7aba851986c47392400bc0a1"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/red-data-tools/red_amber","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/red-data-tools%2Fred_amber","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/red-data-tools%2Fred_amber/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/red-data-tools%2Fred_amber/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/red-data-tools%2Fred_amber/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/red-data-tools","download_url":"https://codeload.github.com/red-data-tools/red_amber/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/red-data-tools%2Fred_amber/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278887173,"owners_count":26063126,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-08T02:00:06.501Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apache-arrow","dataframe","dataframe-library","dataframes","ruby"],"created_at":"2024-12-24T00:15:05.984Z","updated_at":"2025-10-11T09:41:11.468Z","avatar_url":"https://github.com/red-data-tools.png","language":"Ruby","readme":"# RedAmber\n\n[![Gem Version](https://img.shields.io/gem/v/red_amber?color=brightgreen)](https://rubygems.org/gems/red_amber)\n[![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)\n[![Maintainability](https://api.codeclimate.com/v1/badges/b8a745047045d2f49daa/maintainability)](https://codeclimate.com/github/heronshoes/red_amber/maintainability)\n[![Test coverage](https://api.codeclimate.com/v1/badges/b8a745047045d2f49daa/test_coverage)](https://codeclimate.com/github/heronshoes/red_amber/test_coverage)\n[![Doc](https://img.shields.io/badge/docs-latest-blue)](https://red-data-tools.github.io/red_amber/)\n[![Discussions](https://img.shields.io/github/discussions/heronshoes/red_amber)](https://github.com/red-data-tools/red_amber/discussions)\n\nRubyistのためのデータフレームライブラリ.\n\n- Powered by [Red Arrow](https://github.com/apache/arrow/tree/master/ruby/red-arrow)\n[![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)\n- Inspired by the dataframe library [Rover-df](https://github.com/ankane/rover)\n\n[README in English](README.md)\n\n![screenshot from jupyterlab](https://raw.githubusercontent.com/red-data-tools/red_amber/main/doc/image/screenshot.png)\n\n## 概要\n* RedAmberはRubyで書かれたデータフレームライブラリです。[Apache Arrow](https://arrow.apache.org/)の列指向データフォーマットを扱うことができます。\n* Rubyらしいブロックやコレクションを使って、Rubyらしい書き方でデータフレームの操作ができることを目指しています。\n* このリポジトリは[開発コンテナ(Dev Container)](https://containers.dev/)をサポートしているので、RedAmberの操作が容易に[試せます](doc/Dev_Containers.ja.md)。\n* [使用例が豊富なドキュメント](https://red-data-tools.github.io/red_amber/)と、127項目の主な操作例を記載したJupyter Notebookドキュメントがあります。\n\n## 必要な環境\n### Ruby\n- Ruby 3.0 以上.\n\n### ライブラリ\n```ruby\ngem 'red-arrow',   '\u003e= 12.0.0' # お使いの環境に合わせた Apache Arrow が必要です\n                               # 下記のインストールを参照してください\ngem 'red-arrow-numo-narray'    # 必要に応じて。Numo::NArray との連携またはランダムサンプリングが必要な場合。\ngem 'red-parquet', '\u003e= 12.0.0' # 必要に応じて。Parquet の入出力が必要な場合。\ngem 'red-datasets-arrow'       # 必要に応じて。Red Datasets を利用する場合。\ngem 'red-arrow-activerecord'   # 必要に応じて。Active Record とのデータ交換が必要な場合。\ngem 'rover-df'                 # 必要に応じて。Rover::DataFrame に対する入出力が必要な場合。\n```\n\n## インストール\n\nRedAmberをインストールする前に、下記のライブラリのインストールが必要です。\n\n- Apache Arrow (\u003e= 12.0.0)\n- Apache Arrow GLib (\u003e= 12.0.0)\n- Apache Parquet GLib (\u003e= 12.0.0)  # Parquetの入出力が必要な場合。\n\n環境ごとの詳しいインストール方法は、 [Apache Arrow install document](https://arrow.apache.org/install/) を参照してください。\n\n  - Ubuntuの場合の最低限必要なインストール例:\n\n      ```\n      sudo apt update\n      sudo apt install -y -V ca-certificates lsb-release wget\n      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\n      sudo apt install -y -V ./apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb\n      sudo apt update\n      sudo apt install -y -V libarrow-dev libarrow-glib-dev\n      ```\n\n  - Fedora 39 (Rawhide)の場合:\n\n      ```\n      sudo dnf update\n      sudo dnf -y install gcc-c++ libarrow-devel libarrow-glib-devel ruby-devel libyaml-devel\n      ```\n\n  - macOS の場合は、Homebrewを使用する:\n\n      ```\n      brew install apache-arrow apache-arrow-glib\n      ```\n\nApache Arrowがインストールできたら、下記の行をGemfileに追加してください:\n\n```ruby\ngem 'red-arrow',   '\u003e= 12.0.0'\ngem 'red_amber'\ngem 'red-arrow-numo-narray'    # 必要に応じて。Numo::NArray との連携またはランダムサンプリングが必要な場合。\ngem 'red-parquet', '\u003e= 12.0.0' # 必要に応じて。Parquetの入出力が必要な場合。\ngem 'red-datasets-arrow'       # 必要に応じて。Red Datasets を利用する場合。\ngem 'red-arrow-activerecord'   # 必要に応じて。Active Record とのデータ交換が必要な場合。\ngem 'rover-df'                 # 必要に応じて。Rover::DataFrameに対する入出力が必要な場合。\n```\n\n`bundle install`とするか、または `gem install red_amber`としてインストールしてください。\n\n## Development Containersによる開発環境\n\nこのリポジトリは [開発コンテナ(Dev Container)](https://containers.dev/)をサポートしています。\nこれを使うと、ローカルの環境を変更することなく、RedAmberに必要なツール一式を含んだ環境を準備することができます。この環境には、Ruby、Apache Arrow、RedAmberのソースツリー、GitHub CI、サンプルデータセット、IRubyカーネルを含んだJupyter Labなどが含まれています。\n\nRedAmber用のDev Containerは、`.devcontainer` ディレクトリに必要な設定が書かれています。\n使用例は、[開発コンテナ(Development Containers)の利用](doc/Dev_Containers.ja.md)をご参照ください。\n\n## Docker イメージと Jupyter Notebook\n\n（注：将来削除される可能性があります。上記のDev Containerをご活用ください。）\n\nこのリポジトリの`docker` フォルダーから Docker コンテナ環境を生成できます。リポジトリをクローンしてから、dockerフォルダーにある [readme](docker/readme.md) を参照してください。その環境では `docker/notebook` フォルダーにある Jupyter Notebookイメージを試用できます。\n\nこのREADMEの内容をネットワーク上のJupyter Notebookでインタラクティブに試用することも出来ます。 [Binder](https://mybinder.org/v2/gh/heronshoes/docker-stacks/RedAmber-binder?filepath=red-amber.ipynb).\n[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/heronshoes/docker-stacks/RedAmber-binder?filepath=red-amber.ipynb)\n\nJupyter Notebookの環境を含めた他の多くのデータ処理用のライブラリーとともにRedAmberもパッケージングされたDocker Imageとして、[RubyData Docker Stacks](https://github.com/RubyData/docker-stacks) が利用できます(Thanks to Kenta Murata).\n\n## 他のデータフレームライブラリとの比較表\n\nRedAmberの基本的な機能をPython\n[pandas](https://pandas.pydata.org/) や\nR [Tidyverse](https://www.tidyverse.org/) や\nJulia [DataFrames](https://dataframes.juliadata.org/stable/) と比較した表は [DataFrame_Comparison_ja.md](doc/DataFrame_Comparison_ja.md) にあります(Thanks to Benson Muite).\n\n## `RedAmber`のデータフレーム\n\nクラス `RedAmber::DataFrame` は２次元のデータの集まりを表現します。\nその実体は Red Arrowの Tableオブジェクトです。\n\n![dataframe model of RedAmber](https://raw.githubusercontent.com/red-data-tools/red_amber/main/doc/image/dataframe_model.png)\n\nそれではライブラリをロードしていくつかの例を試してみましょう。\n\n```ruby\nrequire 'red_amber' # require 'red-amber' でもOKです.\ninclude RedAmber\n```\n\n### 例: diamonds データセット\n\nもしまだであれば、Red DatasetsのArrow拡張を`\ngem install red-datasets-arrow\n`\nとしてインストールしてから次を実行してください。\n\n```ruby\nrequire 'datasets-arrow' # サンプルデータのロードのため\n\ndataset = Datasets::Diamonds.new\ndiamonds = DataFrame.new(dataset) # v0.2.3以前では, `dataset.to_arrow`とする必要があります。\n\n# =\u003e\n#\u003cRedAmber::DataFrame : 53940 x 10 Vectors, 0x000000000000f668\u003e\n         carat cut       color    clarity     depth    table    price        x ...        z\n      \u003cdouble\u003e \u003cstring\u003e  \u003cstring\u003e \u003cstring\u003e \u003cdouble\u003e \u003cdouble\u003e \u003cuint16\u003e \u003cdouble\u003e ... \u003cdouble\u003e\n    0     0.23 Ideal     E        SI2          61.5     55.0      326     3.95 ...     2.43\n    1     0.21 Premium   E        SI1          59.8     61.0      326     3.89 ...     2.31\n    2     0.23 Good      E        VS1          56.9     65.0      327     4.05 ...     2.31\n    3     0.29 Premium   I        VS2          62.4     58.0      334      4.2 ...     2.63\n    4     0.31 Good      J        SI2          63.3     58.0      335     4.34 ...     2.75\n    :        : :         :        :               :        :        :        : ...        :\n53937      0.7 Very Good D        SI1          62.8     60.0     2757     5.66 ...     3.56\n53938     0.86 Premium   H        SI2          61.0     58.0     2757     6.15 ...     3.74\n53939     0.75 Ideal     D        SI2          62.2     55.0     2757     5.83 ...     3.64\n```\n\n例えば、1カラット以下のレコードに対し、cut毎の平均のpriceを求めるには次のようにします。\n\n```ruby\ndf = diamonds\n  .slice { carat \u003e 1 } # #sliceの代わりに#filterでも可\n  .group(:cut)\n  .mean(:price) # ここで:priceを指定する場合はgroupの前のpickは不要\n  .sort('-mean(price)')\n\n# =\u003e\n#\u003cRedAmber::DataFrame : 5 x 2 Vectors, 0x000000000000f67c\u003e\n  cut       mean(price)\n  \u003cstring\u003e     \u003cdouble\u003e\n0 Ideal         8674.23\n1 Premium       8487.25\n2 Very Good     8340.55\n3 Good           7753.6\n4 Fair          7177.86\n```\n\nArrowのデータはイミュータブルなので、これらのメソッドは新しいオブジェクトを返します。\n\n次の例は、列をリネームしてから新しい列に簡単な計算の結果を格納します。\n\n```ruby\nusdjpy = 110.0 # 今よりずっと円高の頃\n\ndf.rename('mean(price)': :mean_price_USD)\n  .assign(:mean_price_JPY) { mean_price_USD * usdjpy }\n\n# =\u003e\n#\u003cRedAmber::DataFrame : 5 x 3 Vectors, 0x000000000000f71c\u003e\n  cut       mean_price_USD mean_price_JPY\n  \u003cstring\u003e        \u003cdouble\u003e       \u003cdouble\u003e\n0 Ideal            8674.23      954164.93\n1 Premium          8487.25      933597.34\n2 Very Good        8340.55      917460.37\n3 Good              7753.6      852896.11\n4 Fair             7177.86      789564.12\n```\n\n### 例: starwars データセット\n\n次の例は、CSVファイルをダウンロードして`starwars` データセットを読み込みます。その後簡単なデータのクリーニングを行います。\n\n```ruby\nuri = URI('https://vincentarelbundock.github.io/Rdatasets/csv/dplyr/starwars.csv')\n\nstarwars = DataFrame.load(uri)\n\nstarwars\n  .drop(0) # 不要な列を取り除く\n  .remove { species == \"NA\" } # 不要な行を取り除く\n  .group(:species) { [count(:species), mean(:height, :mass)] }\n  .slice { count \u003e 1 } # #filterでも可\n\n# =\u003e\n#\u003cRedAmber::DataFrame : 8 x 4 Vectors, 0x000000000000f848\u003e\n  species    count mean(height) mean(mass)\n  \u003cstring\u003e \u003cint64\u003e     \u003cdouble\u003e   \u003cdouble\u003e\n0 Human         35       176.65      82.78\n1 Droid          6        131.2      69.75\n2 Wookiee        2        231.0      124.0\n3 Gungan         3       208.67       74.0\n4 Zabrak         2        173.0       80.0\n5 Twi'lek        2        179.0       55.0\n6 Mirialan       2        168.0       53.1\n7 Kaminoan       2        221.0       88.0\n```\n\nより詳しいデータフレームの使用例については、[DataFrame.md](doc/DataFrame.md) をご参照ください。\n\n\n### 1次元のデータを保持する `Vector`\n\nクラス`RedAmber::Vector` はデータフレームの中の列方向に格納された１次元のデータ列を保持します.\n\nより詳しい使用例については [Vector.md](doc/Vector.md) をご参照ください。\n\n\n## Jupyter Notebook\n\nこのリポジトリでは [Quarto](https://quarto.org/) を使って、操作例を載せたJupyter Notebookのソースはqmd形式で保存し、gitの管理下に置いています。Notebookの生成は開発コンテナを使うと便利です。詳しくは[開発コンテナ(Development Containers)の利用](doc/Dev_Containers.ja.md)を利用して下さい。\n\n## 開発\n\nDev Containersを利用してコンテナ上に開発環境を作成する方法がお勧めです。[開発コンテナ(Development Containers)の利用例](doc/Dev_Containers.ja.md)を参考にしてください。\n\nまたは、ローカル環境に必要なライブラリをインストールした上で、下記を実行するとテストが走ります。\n\n```shell\ngit clone https://github.com/red-data-tools/red_amber.git\ncd red_amber\nbundle install\nbundle exec rake test\n```\n\nRedAmberの開発では、`rake test` は必須ですが、`rake rubocop` をパスすることはコントリビュートの際に必須ではありません。このプロジェクトではコードの書き方の好みを尊重します。ただしマージの際に書き方を統一させていただくことがあります。\n\n## コミュニティ\n\nこのプロジェクトを支援して頂けると嬉しいです。支援の方法はいくつかあります。\n\n- [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)\n  - Q and Aや使用方法、豆知識などを見ることができます。\n  - 疑問に思っていることを質問できます。\n  - 新しいアイデアを共有する。アイデアはdiscussionからissueに昇格させて育てていくこともあります。漠然としたアイデアでもdiscussionから始めて大きくしていきましょう。\n- [バグ報告や新しい機能の提案](https://github.com/red-data-tools/red_amber/issues)\n- バグの修正や[プルリクエスト](https://github.com/red-data-tools/red_amber/pulls)\n- ドキュメントを修正したり、不明確なところを直したり、新しく追加しましょう。\n皆さんのご参加をお待ちしています。\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","funding_links":[],"categories":["Libraries"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fred-data-tools%2Fred_amber","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fred-data-tools%2Fred_amber","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fred-data-tools%2Fred_amber/lists"}