Polarsとpandasの比較
PolarsとPandasの比較
Pandasが辛くなるほど使い込んでなくて知らないので、ちゃんとした比較はできないmrsekut.icon
ただ、PandasのコードをPolarsに書き直してみてみると、圧倒的に可読性が高いのはわかる
Modern Polars
https://kevinheavey.github.io/modern-polars/
https://github.com/kevinheavey/modern-polars
https://zenn.dev/hiro_torii/articles/06d7e845e146ee#pandasとの違い
https://qiita.com/_jinta/items/fac13f09e8e8a5769b79#pandasとの比較
PolarsのほうがAIのサポートがまだ弱い
もっと良い例ありそう
code:py
result = df.select(
pl.col("name"),
pl.col("birthdate").dt.year().alias("birth_year"),
(pl.col("weight") / (pl.col("height") ** 2)).alias("bmi"),
)
print(result)
これをpandasで書くとこんな感じ
code:py
df'birth_year' = df'birthdate'.dt.year
df'bmi' = df'weight' / (df'height' ** 2)
result = df'name', 'birth_year', 'bmi'
print(result)
polarsの方が宣言的に書けると言える?