fp-frame 0.2.0

DataFrame and Series with pandas-API parity, AACE index alignment, and GroupBy / Rolling / Resample integration.
Documentation
//! DataFrame.sort_values(by=col) head-to-head. 500k×5 Float64, shuffled key column.
//! Isolated bench (unique -cc name; committed standalone during a hot shared-tree window).
//!
//! Run: cargo run -p fp-frame --example bench_sortdf_cc --release -- 500000 5 20

use std::{collections::BTreeMap, time::Instant};

use fp_columnar::Column;
use fp_frame::DataFrame;
use fp_index::{Index, IndexLabel};
use fp_types::Scalar;

fn main() {
    let args: Vec<String> = std::env::args().collect();
    let n: usize = args.get(1).and_then(|s| s.parse().ok()).unwrap_or(500_000);
    let k: usize = args.get(2).and_then(|s| s.parse().ok()).unwrap_or(5);
    let iters: usize = args.get(3).and_then(|s| s.parse().ok()).unwrap_or(20);
    let index = Index::new((0..n as i64).map(IndexLabel::Int64).collect());
    let mut cols = BTreeMap::new();
    let mut order = Vec::new();
    let mut st: u64 = 0x51ed_2701_aa17_3c9f;
    for c in 0..k {
        let name = format!("c{c}");
        let vals: Vec<Scalar> = (0..n)
            .map(|i| {
                if c == 0 {
                    st = st.wrapping_mul(6_364_136_223_846_793_005).wrapping_add(1);
                    Scalar::Float64(((st >> 11) as f64) / (1u64 << 53) as f64 * 1e6)
                } else {
                    Scalar::Float64((i + c) as f64 * 1.5)
                }
            })
            .collect();
        cols.insert(name.clone(), Column::from_values(vals).unwrap());
        order.push(name);
    }
    let df = DataFrame::new_with_column_order(index, cols, order).unwrap();

    let mut best = u128::MAX;
    for _ in 0..iters {
        let t = Instant::now();
        let out = df.sort_values("c0", true).expect("sort_values");
        let e = t.elapsed().as_nanos();
        std::hint::black_box(&out);
        if e < best {
            best = e;
        }
    }
    println!("sort_values_df n={n} k={k}: best={best}ns");
}