Polars

高速なデータフレームライブラリ

Polars

PolarsはRustで書かれた高速なデータフレームライブラリです。

Polars

Polarsをインストールする

Polarsはpipコマンドでインストールが可能です。

python -m pip install -U polars

テストスクリプト

Getting startedにあるスクリプトを試してみます。

> vim test.py

test.py

import polars as pl

df = pl.read_csv("https://j.mp/iriscsv")
print(df.filter(pl.col("sepal_length") > 5)
      .groupby("species", maintain_order=True)
      .agg(pl.all().sum())
)

実行すると、こんなふうになる。

> python .\test.py
shape: (3, 5)
┌────────────┬──────────────┬─────────────┬──────────────┬─────────────┐
 species     sepal_length  sepal_width  petal_length  petal_width 
 ---         ---           ---          ---           ---         
 str         f64           f64          f64           f64         
╞════════════╪══════════════╪═════════════╪══════════════╪═════════════╡
 setosa      116.9         81.7         33.2          6.1         
├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌┤
 versicolor  281.9         131.8        202.9         63.3        
├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌┤
 virginica   324.5         146.2        273.1         99.6        
└────────────┴──────────────┴─────────────┴──────────────┴─────────────┘

オブジェクトを作成する

スクラッチから作成する

SeriesDataframeがある。

ファイルから作成する

csv, json, parquetファイルからDataframeを作成する。

See Also

os

OSの機能を使用する

PATH操作

PATH操作するためのモジュール

pprint

オブジェクトを美しく表示するパッケージ

sys

Pythonインタプリタの動作に関する情報を提供するためのモジュール

itertools

iterableなオブジェクトのためのモジュール

Requests

HTTPを扱うためのモジュール

math

数学関数を使用するためのモジュール

Django

PythonベースのWebアプリを作る