Polars Ruby
:fire: Blazingly fast DataFrames for Ruby, powered by Polars
Installation
Add this line to your application’s Gemfile:
gem "polars-df"
Note: Rust is currently required for installation, and it can take 15-20 minutes to compile the extension.
Getting Started
This library follows the Polars Python API.
Polars.read_csv("iris.csv")
.lazy
.filter(Polars.col("sepal_length") > 5)
.groupby("species")
.agg(Polars.all.sum)
.collect
You can follow Polars tutorials and convert the code to Ruby in many cases. Feel free to open an issue if you run into problems. Note that many methods and options are missing at the moment.
Examples
Creating DataFrames
From a CSV
Polars.read_csv("file.csv")
From Parquet
Polars.read_parquet("file.parquet")
From Active Record
Polars::DataFrame.new(User.all)
From a hash
Polars::DataFrame.new({
a: [1, 2, 3],
b: ["one", "two", "three"]
})
From an array of series
Polars::DataFrame.new([
Polars::Series.new("a", [1, 2, 3]),
Polars::Series.new("b", ["one", "two", "three"])
])
History
View the changelog
Contributing
Everyone is encouraged to help improve this project. Here are a few ways you can help:
- Report bugs
- Fix bugs and submit pull requests
- Write, clarify, or fix documentation
- Suggest or add new features
To get started with development:
git clone https://github.com/ankane/polars-ruby.git
cd polars-ruby
bundle install
bundle exec rake compile
bundle exec rake test