Skip to content
Cookbook

Cookbook

Practical recipes for common data manipulation tasks with Molniya.

This cookbook contains patterns and solutions for everyday data processing needs. Each recipe is self-contained and can be adapted to your specific use case.

Recipe Categories

Data Selection

Data Transformation

Data Aggregation

Data Combination

String Processing

Quick Reference

Common Patterns

typescript
// Filter and select
df.filter(col("status").eq("active")).select("id", "name")

// Add computed column
df.withColumn("total", col("price").add(col("tax")))

// Group and aggregate
df.groupBy("category", [
  { name: "sum", expr: sum("amount") },
  { name: "count", expr: count() }
])

// Sort and limit
df.sort(desc("amount")).limit(10)

// Chain everything
const result = await df
  .filter(col("year").eq(2024))
  .withColumn("discounted", col("price").mul(0.9))
  .groupBy("category", [
    { name: "total", expr: sum("discounted") }
  ])
  .sort(desc("total"))
  .limit(5)
  .toArray();

Before You Start

Most recipes assume you have:

typescript
import { 
  readCsv, fromRecords, col, lit, and, or, not,
  sum, avg, min, max, count, asc, desc, DType 
} from "molniya";

Need More Help?