talon

pandas ergonomics. Polars performance. OCaml's type safety.


why talon?

type-safe row operations

Work with heterogeneous columns safely. The compiler ensures your row operations match column types.

optimized for wide dataframes

Efficient handling of 100+ columns. Vectorized operations that scale with your data.

familiar yet functional

pandas-like API with functional programming. Use applicative functors for elegant row transformations.

built on nx

Leverages Nx arrays for fast computation. Seamlessly integrates with the Raven ecosystem.


show me the code

PANDAS

# Create dataframe
df = pd.DataFrame({
  'name': ['Alice', 'Bob'],
  'age': [25, 30],
  'height': [1.70, 1.80]
})

# Add BMI column
df['bmi'] = (
  df['weight'] / 
  df['height']**2
)

# Row-wise sum
df['total'] = df[['a', 'b', 'c']].sum(axis=1)

# Can fail at runtime
df['bad'] = df['age'] + df['name']  # TypeError!

TALON

(* Create dataframe *)
let df = create [
  ("name", Col.string_list ["Alice"; "Bob"]);
  ("age", Col.int32_list [25l; 30l]);
  ("height", Col.float64_list [1.70; 1.80])
]

(* Add BMI column *)
let df = with_column df "bmi" Nx.float64
  Row.(map2 (number "weight") (number "height") 
    ~f:(fun w h -> w /. (h ** 2.)))

(* Row-wise sum *)
let total = Row.Agg.sum df ~names:["a"; "b"; "c"]

(* This won't compile - type error! *)
(* let bad = Row.(map2 (int32 "age") (string "name") ~f:(+)) *)

the good parts

Wide operations that scale
Process 100+ columns efficiently with vectorized operations. No more iterating row by row.

Type-safe heterogeneous data
Mix strings, floats, integers, and booleans. GADTs ensure type safety at compile time.

Functional transformations
Use applicative functors for elegant row-wise operations. Compose transformations with map, filter, and fold.

pandas-compatible operations
Join, merge, pivot, melt, groupby. All the operations you know, with better performance.


ergonomic apis

(* Column selectors *)
let numeric_cols = Cols.numeric df
let price_cols = Cols.with_prefix df "price_"

(* Batch column operations *)
let df = with_columns df [
  ("total", Row.Agg.sum df ~names:numeric_cols);
  ("avg", Row.Agg.mean df ~names:price_cols)
]

(* Functional row operations *)
let df = with_columns_map df
  Row.([
    ("sum", Nx.float64, map2 (number "a") (number "b") ~f:( +. ));
    ("diff", Nx.float64, map2 (number "a") (number "b") ~f:( -. ))
  ])

get started

Talon isn't released yet. For now, check out the documentation to learn more.

When it's ready:

# Install
opam install talon

# Try it
open Talon

let () = 
  let df = create [
    ("x", Col.float64_list [1.; 2.; 3.]);
    ("y", Col.float64_list [4.; 5.; 6.])
  ] in
  print df