使用Bun和nodejs-polars进行数据分析(前半部分)
首先
使用Bun和nodejs-polars可以快速地进行数据处理和其他附加功能!
关于Node.js的polars
polarsのサイトを見てると、nodejsでも実行できるんだーエッ!となり、データ加工のみならpythonいらなくなるじゃんと思ったのをきっかけに情報収集を開始。
この方↓のtweetを見かけて、さらにBunという存在を知る。確かに突然javascriptですごいスピードのデータ加工ができるようになる可能性。mapやreduceでも何かできるのではと思ってたけど、慣れてる方法でできる(しかも速い)ならありがたい。

关于Bun

4. 我试着做了一下。 (Wǒ .)
在 Github Codespaces 上,不再需要本地编辑器了呢。
把包子放进去。
照公式網站的指示(這個角色真是奇怪啊)
curl -fsSL https://bun.sh/install | bash
bun http.js


安装4.2版本的noejs-polars。
nodejs-polarsを入れる。
bun add nodejs-polars
bun add bun-types //autocomplete用

借用nodejs-polars官方上的内容。
// http.js
//import Database from "bun:sqlite"; //本当は使いたかったが適当なsqliteデータがないので断ね
//import pl from "nodejs-polars";
const pl = require("nodejs-polars");
const fooSeries = pl.Series("foo", [1, 2, 3]);
console.log(fooSeries);
const dispval = JSON.stringify(fooSeries.toArray());
const df = pl.DataFrame({
A: [1, 2, 3, 4, 5],
fruits: ["banana", "banana", "apple", "apple", "banana"],
B: [5, 4, 3, 2, 1],
cars: ["beetle", "audi", "beetle", "beetle", "beetle"],
});
console.log(df);
export default {
port: 3000,
fetch(request) {
return new Response(dispval);
},
};


确实动起来了!
正在进行试验,是否可以通过将cytoscape.js与服务器端的JavaScript结合起来,实现网络分析和可视化。