この CSV の例では、
Source,col1,col2,col3
foo,1,2,3
bar,3,4,5
私が Pandas を使用する標準的な方法は次のとおりです。
CSVを解析する
データフレームに列を選択する(
col1
およびcol3
)- 列を処理する(例:
col1
との値の平均をとるcol3
)
Pandas のようにそれを実行する JavaScript ライブラリはありますか?
ベストアンサー1
このウィキでは、多くのパンダのような JavaScript ライブラリを要約して比較します。
一般的に、d3 JavaScript ライブラリをチェックする必要があります。d3 は、Python で pandas が役立つのと同じように、JavaScript でデータを処理するための非常に便利な「スイス アーミー ナイフ」です。d3 が DataFrame/Pandas の代替品ではない場合でも (つまり、d3 には同じ API がなく、d3 には pandas の動作に一致するメソッドを持つSeries
/DataFrame
クラスがありません)、pandas のように d3 が頻繁に使用されているのを目にするかもしれません。
アハメドの回答ではd3の使い方が説明されているいくつかのDataFrame機能を実現するために、以下のライブラリのいくつかは次のようなものからインスピレーションを得ました。学習JsDatad3 と lodash を使用します。
DataFrame スタイルのデータ変換 (分割、結合、グループ化など) については、いくつかの JavaScript ライブラリの簡単なリストを以下に示します。
ライブラリは、次のようなさまざまな言語で記述されていることに注意してください。
- ブラウザ互換、つまりクライアントサイドJavaScript
- Node.js 別名サーバーサイド JavaScript
- タイプスクリプト
- 中には、WebAssembly にトランスパイルされた CPython を使用するものもあります (ただし、Node.js やブラウザで動作します)
...自分に合ったオプションを使用してください:
- ピオディデ(ブラウザサポートとNodejsサポート)
- 新しくて非常に強力な候補アハメド・ファシの回答
- CPython と数値 Python エコシステムの大部分 (「NumPy、pandas、SciPy、Matplotlib、scikit-learn を含む」) の WebAssembly トランスパイル、「ブラウザと Node.js 用」
- プロジェクトJupyterに深く関わる人々によって作られた
- 見る含まれるパッケージのリスト
- ダンフォ-js(browser-support AND NodeJS-support)
From Vignesh's answer
danfo (which is often imported and aliased as
dfd
); has a basic DataFrame-type data structure, with the ability to plot directlyBuilt by the team at Tensorflow: "One of the main goals of Danfo.js is to bring data processing, machine learning and AI tools to JavaScript developers. ... Open-source libraries like Numpy and Pandas..."
pandas is built on top of numpy; likewise danfo-js is built on tensorflow-js
please note danfo may not (yet?) support multi-column indexes
- pandas-js
- UPDATE The pandas-js repo has not been updated in awhile
- From STEEL and Feras' answers
- "pandas.js is an open source (experimental) library mimicking the Python pandas library. It relies on Immutable.js as the NumPy logical equivalent. The main data objects in pandas.js are, like in Python pandas, the Series and the DataFrame."
- dataframe-js
- "DataFrame-js provides an immutable data structure for javascript and datascience, the DataFrame, which allows to work on rows and columns with a sql and functional programming inspired api."
- data-forge
- Seen in Ashley Davis' answer
- "JavaScript data transformation and analysis toolkit inspired by Pandas and LINQ."
- Note the old data-forge JS repository is no longer maintained; now a new repository uses Typescript
- jsdataframe
- "Jsdataframe is a JavaScript data wrangling library inspired by data frame functionality in R and Python Pandas."
- dataframe
- "explore data by grouping and reducing."
- SQL Frames
- "DataFrames meet SQL, in the Browser"
- "SQL Frames is a low code data management framework that can be directly embedded in the browser to provide rich data visualization and UX. Complex DataFrames can be composed using familiar SQL constructs. With its powerful built-in analytics engine, data sources can come in any shape, form and frequency and they can be analyzed directly within the browser. It allows scaling to big data backends by transpiling the composed DataFrame logic to SQL."
- Jandas (browser- AND NodeJS-support; a new TypeScript library developed in 2023)
- Indexing and query very similar to Pandas
- Negative number and range indexing
- Support DataFrame with zero rows/columns
- Support index with duplicated values
- iterrows, sort_values, groupby and element-wise operation
Then after coming to this question, checking other answers here and doing more searching, I found options like:
- Apache Arrow in JS
- Thanks to user Back2Basics suggestion:
- "Apache Arrow is a columnar memory layout specification for encoding vectors and table-like containers of flat and nested data. Apache Arrow is the emerging standard for large in-memory columnar data (Spark, Pandas, Drill, Graphistry, ...)"
- polars
- Polars is a blazingly fast DataFrames library implemented in Rust using Apache Arrow Columnar Format as memory model.
- Observable
- ポータル(以前は
recline
;からルーファスの答え)- 古くなっている可能性があります:「DataFrame」APIは使用しません
- 古くなっている可能性があります:代わりに、jQuery を必要としないがブラウザを必要とする「マルチビュー」(UI) API (jQuery/DOM モデルに類似) を強調します。その他の例
- 古くなっている可能性があります:また、MVC風のアーキテクチャ; バックエンドのもの(データベース接続など)を含む
- jsデータ
- 味噌(もう一つの提案ルーファス)
- アラSQL
- 「AlaSQL」は、リレーショナル データとスキーマレス データの両方に対するクエリ速度とデータ ソースの柔軟性に重点を置いた、Javascript 用のオープン ソース SQL データベースです。ブラウザー、Node.js、Cordova で動作します。
- いくつかの思考実験:
上記の選択を検討する際に使用した基準は次のとおりです。