Polars.FSharp 0.1.0-alpha1

This is a prerelease version of Polars.FSharp.
There is a newer version of this package available.
See the version list below for details.
dotnet add package Polars.FSharp --version 0.1.0-alpha1
                    
NuGet\Install-Package Polars.FSharp -Version 0.1.0-alpha1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Polars.FSharp" Version="0.1.0-alpha1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Polars.FSharp" Version="0.1.0-alpha1" />
                    
Directory.Packages.props
<PackageReference Include="Polars.FSharp" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Polars.FSharp --version 0.1.0-alpha1
                    
#r "nuget: Polars.FSharp, 0.1.0-alpha1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Polars.FSharp@0.1.0-alpha1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Polars.FSharp&version=0.1.0-alpha1&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Polars.FSharp&version=0.1.0-alpha1&prerelease
                    
Install as a Cake Tool

Polars.NET

πŸš€ High-Performance, AI-Ready DataFrames for .NET, powered by Rust & Apache Arrow.

Polars.NET is not just a binding; it is a production-grade data engineering toolkit for the .NET ecosystem. It brings the lightning-fast performance of the Polars Rust engine to C# and F#, while adding unique, enterprise-ready features missing from official bindingsβ€”like seamless Database Streaming, Zero-Copy Interop, and AI-native Vector support.

Why Polars.NET exists

The .NET ecosystem deserves a first-class, production-grade DataFrame engine β€” not a thin wrapper, not a toy binding, and not a Python dependency in disguise.

Polars.NET is designed for engineers who care about:

  • predictable performance

  • strong typing

  • streaming data at scale

  • and long-term system evolution

Why Polars.NET?

  1. ⚑ Unmatched Performance
  • Rust Core: Built on the blazing fast Polars query engine (written in Rust).

  • Lazy Evaluation: Intelligent query optimizer with predicate pushdown, projection pushdown, and parallel execution.

  • Zero-Copy: Built on Apache Arrow, enabling zero-copy data transfer between C#, Python, and databases.

  1. πŸ›‘οΈ Enterprise & AI Ready
  • Database Streaming (Unique):

    • Read: Stream millions of rows from any IDataReader (SQL Server, Postgres, SQLite) directly into Polars without loading everything into RAM.

    • Write: Stream processed data back to databases via IBulkCopy interfaces using our unique ArrowToDbStream adapter.

  • AI / Vector Support: First-class support for FixedSizeList (Array) columns. Perform high-performance vector operations (Dot Product, Cosine Similarity, Aggregations) directly in the engineβ€”perfect for RAG and Embedding workflows.

  1. 🧢 .NET Native Experience

    • Fluent API: Intuitive, LINQ-like API design for C#.

    • Functional API: Idiomatic, pipe-forward (|>) API for F# lovers.

    • Type Safety: Leveraging .NET's strong type system to prevent runtime errors.

πŸ“¦ Installation

dotnet add package Polars.NET

Target Framework

.NET 8 and

🏁 Quick Start

C# Example

using Polars.CSharp;
using static Polars.CSharp.Polars; // For Col(), Lit() helpers

// 1. Create a DataFrame
var data = new[] {
    new { Name = "Alice", Age = 25, Dept = "IT" },
    new { Name = "Bob", Age = 30, Dept = "HR" },
    new { Name = "Charlie", Age = 35, Dept = "IT" }
};
using var df = DataFrame.From(data);

// 2. Filter & Aggregate
using var res = df
    .Filter(Col("Age") > 28)
    .GroupBy("Dept")
    .Agg(
        Col("Age").Mean().Alias("AvgAge"),
        Col("Name").Count().Alias("Count")
    )
    .Sort("AvgAge", descending: true);

// 3. Output
res.Show();

F# Example


open Polars.FSharp

// 1. Scan CSV (Lazy)
let lf = LazyFrame.ScanCsv "users.csv"

// 2. Transform Pipeline
let res = 
    lf
    |> pl.filterLazy (pl.col "age" .> pl.lit 28)
    |> pl.groupByLazy 
        [ pl.col "dept" ]
        [ 
            pl.col("age").Mean().Alias "AvgAge" 
            pl.col("name").Count().Alias "Count"
        ]
    |> pl.collect
    |> pl.sort ("AvgAge", false)

// 3. Output
res.Show()

πŸ”₯ Killer Features (The "Missing" Parts)

  1. 🌊 Streaming ETL: Database β†’ Polars β†’ Database

Process millions of rows with constant memory usage using our unique streaming adapters.

// 1. Source: Stream from Database (e.g., SqlDataReader)
// We scan the DB via a factory, pulling 50k rows at a time into Apache Arrow batches.
var lf = LazyFrame.ScanDb(() => mySqlCommand.ExecuteReader(), batchSize: 50_000);

// 2. Transform: Lazy Evaluation (Rust Engine)
// No data is loaded yet. We are building a query plan.
var pipeline = lf
    .Filter(Col("Region") == Lit("US"))
    .WithColumn((Col("Amount") * 1.08).Alias("TaxedAmount"))
    .Select("OrderId", "TaxedAmount", "OrderDate");

// 3. Sink: Stream back to Database (e.g., SqlBulkCopy)
// We expose the processed stream as an IDataReader implementation!
pipeline.SinkTo((IDataReader reader) => 
{
    // This reader pulls data from the Rust engine on-demand.
    // Perfect for SqlBulkCopy.WriteToServer(reader)
    using var bulk = new SqlBulkCopy(connectionString);
    bulk.DestinationTableName = "ProcessedOrders";
    bulk.WriteToServer(reader);
});
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     Arrow Batches     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Database    β”‚ ───────────────────▢ β”‚ Polars Coreβ”‚
β”‚ (IDataReader)β”‚                       β”‚   (Rust)   β”‚
β””β”€β”€β”€β”€β”€β–²β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ◀─────────────────── β”‚            β”‚
      β”‚        Zero-Copy Stream        β””β”€β”€β”€β”€β”€β–²β”€β”€β”€β”€β”€β”€β”˜
      β”‚                                      β”‚
      β”‚                                      β”‚ FFI
β”Œβ”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”                               β”‚
β”‚   .NET API β”‚ β—€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚ (C# / F#)  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
  1. 🧠 Vector / Embedding Operations

Native support for Array (Fixed-Size List) types, enabling high-performance AI workflows.

// Scenario: RAG - Calculate Cosine Similarity between Query and Document Embeddings
using var df = DataFrame.FromColumns(new { 
    DocId = new[] { 1, 2 },
    Embedding = new[] { new[] {0.1, 0.2}, new[] {0.5, 0.8} } // Array<Float64, 2>
});

var queryVec = new[] { 0.1, 0.2 }; // Query Embedding

var res = df.Lazy()
    .Select(
        Col("DocId"),
        // Calculate Dot Product & Similarity efficiently
        (Col("Embedding") * Lit(queryVec)).Array.Sum().Alias("Score")
    )
    .TopK(1, "Score") // Get Top 1 match
    .Collect();
  1. πŸ•’ Time Series Intelligence

Robust support for time-series data, including As-Of Joins and Dynamic Rolling Windows.

// As-Of Join: Match trades to the nearest quote within 2 seconds
var trades = dfTrades.Lazy(); // timestamp, ticker, price
var quotes = dfQuotes.Lazy(); // timestamp, ticker, bid

var enriched = trades.JoinAsOf(
    quotes, 
    leftOn: Col("timestamp"), 
    rightOn: Col("timestamp"),
    by: [Col("ticker")],      // Match on same Ticker
    tolerance: "2s",          // Look back max 2 seconds
    strategy: "backward"      // Find previous quote
);
// F# Dynamic Rolling Window
lf
|> pl.groupByDynamic "time" (TimeSpan.FromHours 1.0)
    [ pl.col("value").Mean().Alias("hourly_mean") ]
|> pl.collect

πŸ—ΊοΈ Roadmap & Documentation

We are actively working on detailed API documentation.

- Auto-generated API Reference (HTML)

- Advanced Recipes (Time Series, Vector Search)

🀝 Contributing

Contributions are welcome! Whether it's adding new expression mappings, improving documentation, or optimizing the FFI layer.

  1. Fork the repo.

  2. Create your feature branch.

  3. Submit a Pull Request.

πŸ“„ License

MIT License. See LICENSE for details.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Polars.FSharp:

Package Downloads
Polars.NET.Linq

LINQ Translation Engine for Polars.NET and Polars.FSharp. Write strong-typed C#/F# queries and execute them at native speed

Polars.NET.ML

The Machine Learning extension for Polars.NET. This package provides high-speed data bridges between Polars DataFrames, Apache Arrow memory, ML.NET (IDataView). Unlock hardware-accelerated SIMD math, train classic ML models, and seamlessly integrate with deep learning pipelines (ONNX).

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.5.0 46 5/26/2026
0.4.0 154 3/20/2026
0.3.1 111 2/28/2026
0.3.0 72 2/26/2026
0.2.1-beta1 78 2/6/2026
0.2.0-beta1 72 2/4/2026
0.1.0-beta1 77 1/14/2026
0.1.0-alpha2 86 1/10/2026
0.1.0-alpha1 82 1/4/2026