tsb

A TypeScript port of pandas, built from first principles

πŸ—οΈ Active Development β€” Core Structures Complete

pandas for TypeScript

tsb is a ground-up TypeScript implementation of the pandas data manipulation library, with full API parity, strict types, and an interactive playground for every feature.

Feature Roadmap

πŸ“ Project Foundation

Bun, TypeScript (strict), Biome linting, CI, Pages deployment, type system.

βœ… Complete

πŸ“Š Series

1-D labeled array. The core building block of tsb data structures.

βœ… Complete

πŸ—ƒοΈ DataFrame

2-D labeled table. Column-oriented storage, full pandas API.

βœ… Complete

🏷️ Index

Immutable labeled axis, RangeIndex.

βœ… Complete

πŸ”’ Dtypes

Rich dtype system. int/float/bool/string/datetime/category.

βœ… Complete

πŸ”€ GroupBy

Split-apply-combine. groupby, agg, transform, apply, filter.

βœ… Complete

πŸ”— concat

Combine Series and DataFrames. axis=0/1, outer/inner join, ignoreIndex.

βœ… Complete

πŸ”€ merge

SQL-style DataFrame joins. inner/left/right/outer, on/left_on/right_on, suffixes.

βœ… Complete

πŸ”‘ str accessor

Vectorised string operations. lower/upper/strip/pad/contains/replace/split/extract & predicates.

βœ… Complete

πŸ“… dt accessor

Vectorised datetime operations. Calendar components, boolean boundaries, strftime, floor/ceil/round.

βœ… Complete

πŸ“Š describe

Summary statistics. count/mean/std/min/percentiles/max for numeric; count/unique/top/freq for categorical. Series.quantile().

βœ… Complete

πŸ“₯ I/O

CSV I/O. readCsv / toCsv with dtype inference, NA handling, quoted fields, custom separators.

βœ… Complete

πŸ“₯ JSON I/O

JSON I/O. readJson / toJson with five orient formats: records, split, index, columns, values.

βœ… Complete

πŸ“ˆ corr & cov

Pearson correlation & covariance. Series.corr(), DataFrame.corr(), DataFrame.cov(), dataFrameCorr(), dataFrameCov() with index alignment, null handling, and configurable ddof/minPeriods.

βœ… Complete

πŸͺŸ rolling

Sliding-window aggregations. Series.rolling() and DataFrame.rolling() with mean, sum, std, var, min, max, count, median, apply. Supports minPeriods and centered windows.

βœ… Complete

πŸ“ˆ expanding

Growing-window aggregations. Series.expanding() and DataFrame.expanding() with mean, sum, std, var, min, max, count, median, apply. Window grows from start to current position.

βœ… Complete

🏷️ cat accessor

Categorical operations. Series.cat with categories, codes, ordered, addCategories, removeCategories, renameCategories, setCategories, reorderCategories, valueCounts.

βœ… Complete

πŸ“‰ ewm

Exponentially Weighted Moving aggregations. Series.ewm() and DataFrame.ewm() with mean, std, var, cov, corr, apply. Decay via span, com, halflife, or alpha. Supports adjust and ignoreNa.

βœ… Complete

πŸ”€ melt

Wide-to-long reshape. Unpivot columns into variable/value pairs with id_vars, value_vars, var_name, value_name.

βœ… Complete

πŸ”„ pivot & pivotTable

Reshape with aggregation. pivot() for unique reshaping; pivotTable() for aggregation (mean/sum/count/min/max/first/last) with fill_value and dropna support.

βœ… Complete

πŸ“ stack & unstack

Pivot column labels to/from row index. stack() rotates columns into a compound-index Series; unstack() recovers the DataFrame. Custom sep, dropna, and fill_value support.

βœ… Complete

πŸ† rank

Assign numerical ranks to values. rankSeries() and rankDataFrame() with tie methods (average/min/max/first/dense), NaN handling (keep/top/bottom), percentage ranks, and axis support.

βœ… Complete

πŸ” nlargest / nsmallest

Return the n largest or smallest values. nlargestSeries(), nsmallestSeries(), nlargestDataFrame(), nsmallestDataFrame() with keep='first'/'last'/'all' tie-handling, NaN exclusion, and multi-column DataFrame sorting.

βœ… Complete

πŸ“ˆ cumulative operations

Compute running totals, products, maxima, and minima. cumsum(), cumprod(), cummax(), cummin() for Series and DataFrame with skipna support and axis=0/1.

βœ… Complete

βœ‚οΈ element-wise ops

Element-wise transformations. clip(), seriesAbs(), seriesRound() for Series and DataFrame with min/max bounds, decimal precision, and axis support.

βœ… Complete

πŸ”’ value_counts

Count unique values. valueCounts() for Series and dataFrameValueCounts() for DataFrame with normalize, sort, ascending, and dropna options.

βœ… Complete

πŸ—‚οΈ MultiIndex

Hierarchical indexing. MultiIndex for multi-level row and column labels with fromArrays, fromTuples, fromProduct, level access, and swapLevels.

βœ… Complete

πŸ“₯ insertColumn / popColumn

Insert and remove DataFrame columns at precise positions. insertColumn(df, loc, col, values) inserts at integer position, popColumn(df, col) returns { series, df }. Also includes reorderColumns and moveColumn. Mirrors pandas.DataFrame.insert() and .pop().

βœ… Complete

βœ‚οΈ cut / qcut

Bin continuous numeric data into discrete intervals. cut() uses fixed-width or explicit bin edges; qcut() uses quantile-based bins of equal population. Both return codes, labels, and bin edges. Mirrors pandas.cut and pandas.qcut.

βœ… Complete

πŸ“Š Rolling Extended Stats

Higher-order rolling window statistics: rollingSem (standard error of mean), rollingSkew (Fisher-Pearson skewness), rollingKurt (excess kurtosis), and rollingQuantile (arbitrary percentile with 5 interpolation methods). Mirrors pandas.Series.rolling().sem/skew/kurt/quantile().

βœ… Complete

πŸ”§ Rolling Apply & Multi-Agg

Standalone custom rolling-window functions: rollingApply (custom fn per window), rollingAgg (multiple named aggregations β†’ DataFrame), dataFrameRollingApply, dataFrameRollingAgg. Supports minPeriods, center, and raw mode. Mirrors pandas.Rolling.apply() and Rolling.agg().

βœ… Complete

🎭 where / mask

Element-wise conditional selection: seriesWhere / seriesMask and dataFrameWhere / dataFrameMask. Accepts boolean arrays, label-aligned boolean Series/DataFrame, or callables. Mirrors pandas.Series.where, pandas.DataFrame.where, and their .mask() inverses.

βœ… Complete

πŸ”Ž query / eval

Filter rows or evaluate expressions using a pandas-style expression string. queryDataFrame(df, "col > 5 and label in ['a', 'b']") and evalDataFrame(df, "price * qty"). Supports arithmetic, comparisons, logical operators, membership tests, backtick-quoted column names, and built-in functions (abs, round, isnull, lower, …). Mirrors pandas.DataFrame.query and pandas.DataFrame.eval.

βœ… Complete

πŸ” isna / notna

Module-level missing-value detection: isna, notna, isnull, notnull work on scalars, arrays, Series, and DataFrames. Plus standalone fillna, dropna, countna, and countValid. Mirrors pandas.isna, pandas.notna, pandas.isnull, pandas.notnull.

βœ… Complete

🏷️ attrs β€” User Metadata

Attach arbitrary key→value metadata to any Series or DataFrame via a WeakMap registry. Provides getAttrs, setAttrs, updateAttrs, copyAttrs, withAttrs, mergeAttrs, clearAttrs, getAttr, setAttr, deleteAttr, attrsCount, attrsKeys. Mirrors pandas.DataFrame.attrs / pandas.Series.attrs.

βœ… Complete

πŸ”€ string_ops β€” Standalone String Ops

Module-level string utilities: strNormalize (Unicode NFC/NFD/NFKC/NFKD), strGetDummies (one-hot DataFrame), strExtractAll (all regex matches), strRemovePrefix, strRemoveSuffix, strTranslate (char-level substitution), strCharWidth (CJK-aware display width), strByteLength. Works on Series, arrays, or scalars.

βœ… Complete

πŸ”€ string_ops_extended β€” Extended String Ops

Advanced string utilities: strSplitExpand (split β†’ DataFrame columns), strExtractGroups (regex capture groups β†’ DataFrame), strPartition / strRPartition (split into before/sep/after), strMultiReplace (batch replacements), strIndent / strDedent (line-level indentation). Works on Series, arrays, or scalars.

βœ… Complete

πŸ”— pipe_apply β€” Pipeline & Apply Utilities

Standalone equivalents of pandas' pipe() / apply() / applymap(): pipe (variadic type-safe pipeline), seriesApply (element-wise with label/pos context), seriesTransform, dataFrameApply (axis 0/1), dataFrameApplyMap (cell-wise), dataFrameTransform (column-wise), dataFrameTransformRows (row-wise).

βœ… Complete

πŸ”’ numeric_extended β€” Numeric Utilities

numpy/scipy-style numeric utilities: digitize (bin values), histogram (frequency counts with density option), linspace / arange (number sequences), percentileOfScore (percentile rank of a score), zscore (z-score standardisation), minMaxNormalize (scale to [0,1] or custom range), coefficientOfVariation (std/mean). Series-aware variants included.

βœ… Complete

🏷️ categorical_ops β€” Categorical Utilities

Standalone categorical helpers: catFromCodes (from integer codes), set operations (catUnionCategories, catIntersectCategories, catDiffCategories, catEqualCategories), catSortByFreq, catToOrdinal, catFreqTable, catCrossTab, catRecode.

βœ… Complete

πŸ”’ format_ops β€” Number Formatting

Number-formatting helpers for Series and DataFrame. Scalar formatters: formatFloat, formatPercent, formatScientific, formatEngineering, formatThousands, formatCurrency, formatCompact. Formatter factories: makeFloatFormatter, makePercentFormatter, makeCurrencyFormatter. Apply to collections: applySeriesFormatter, applyDataFrameFormatter. Render to string: seriesToString, dataFrameToString.

βœ… Complete

πŸ“— Excel I/O

XLSX file reading. readExcel() parses Excel files from a Uint8Array/ArrayBuffer β€” ZIP+XML parsing from scratch, shared strings, number/string/boolean cells, sheet selection, header, indexCol, skipRows, nrows.

βœ… Complete

πŸ” missing-value ops

Detect and fill missing values. isna(), notna(), isnull(), notnull() for scalars/Series/DataFrame. ffillSeries(), bfillSeries(), dataFrameFfill(), dataFrameBfill() with optional limit and axis support.

βœ… Complete

πŸ“ˆ diff / shift

Discrete difference and value shifting for Series and DataFrame. diff computes element-wise differences; shift lags or leads values by a number of periods. Essential for time-series analysis.

βœ… Complete

πŸ”’ NaN-Ignoring Aggregates

Top-level nan-ignoring aggregate functions: nansum, nanmean, nanmedian, nanstd, nanvar, nanmin, nanmax, nanprod, nancount. Mirrors numpy.nan* functions. Works on arrays and Series.

βœ… Complete

⏱️ toTimedelta

Convert scalars, arrays, or Series to Timedelta objects. Accepts pandas-style strings, ISO 8601, human-readable, and numeric values. Timedelta class with arithmetic: add/subtract/scale/abs/lt/gt/eq.

βœ… Complete

⏳ timedelta_range

Generate fixed-frequency TimedeltaIndex sequences. Supports start/end/periods/freq combinations, multiplier prefixes (e.g. "2H", "30min"), linear spacing, and closed endpoint control.

βœ… Complete

πŸ” strFindall & toJsonDenormalize

strFindall/strFindallCount/strFindFirst/strFindallExpand β€” regex match extraction per element (mirrors pandas str.findall). toJsonDenormalize/toJsonRecords/toJsonSplit/toJsonIndex β€” serialize DataFrames to nested or flat JSON.

βœ… Complete

πŸ“Š cutBinsToFrame

Convert cut/qcut BinResult into a tidy summary DataFrame. cutBinsToFrame returns bin labels, edges, counts, and frequencies. cutBinCounts returns a label→count dict. binEdges returns an edges-only DataFrame.

βœ… Complete

βœ‚οΈ xs β€” Cross-Section

xsDataFrame / xsSeries β€” select rows or columns by label (mirrors pandas .xs()). Supports flat and MultiIndex, axis selection, level targeting, and dropLevel control.

βœ… Complete

↔️ between β€” Range Check

seriesBetween β€” element-wise range check returning a boolean Series. Mirrors pandas Series.between(). Supports inclusive="both"|"left"|"right"|"neither".

βœ… Complete

πŸ”„ update β€” In-place Update

seriesUpdate / dataFrameUpdate β€” update values from another object using label alignment. Non-NA values in other overwrite self. Mirrors pandas DataFrame.update().

βœ… Complete

πŸ”½ filter β€” Filter Labels

filterDataFrame / filterSeries β€” filter rows or columns by label using items list, substring (like), or regex pattern. Mirrors pandas DataFrame.filter().

βœ… Complete

πŸ”€ combine β€” Element-wise Combination

combineSeries / combineDataFrame β€” combine two objects element-wise with a caller-supplied binary function. Result index is the union of both indices. Mirrors pandas Series.combine() / DataFrame.combine().

βœ… Complete

βœ… keepTrue / keepFalse / filterBy β€” Boolean Indexing

keepTrue / keepFalse / filterBy β€” boolean-mask selection helpers for Series and DataFrames. Mirrors pandas boolean indexing (series[mask], df[mask]).

βœ… Complete

πŸ”’ scalar_extract β€” squeeze / item / bool / first_valid_index

squeezeSeries / squeezeDataFrame / itemSeries / boolSeries / boolDataFrame / firstValidIndex / lastValidIndex β€” scalar-extraction helpers for Series and DataFrames. Mirrors pandas Series.squeeze(), item(), bool(), first_valid_index(), last_valid_index().

βœ… Complete

πŸ“Š corrWith / autoCorr β€” Pairwise Correlation & Autocorrelation

corrWith / autoCorr β€” compute pairwise Pearson correlations between a DataFrame and a Series or DataFrame, and compute lag-N autocorrelation for a Series. Mirrors pandas DataFrame.corrwith() and Series.autocorr().

βœ… Complete

πŸ”— join / joinAll / crossJoin β€” Label-Based Joins

join / joinAll / crossJoin β€” join DataFrames by index labels or a key column. join() defaults to left-join-on-index, joinAll() chains multiple joins, crossJoin() produces the Cartesian product. Mirrors pandas DataFrame.join().

βœ… Complete

⏱️ merge_asof β€” Ordered Nearest-Key Join

mergeAsof β€” ordered left-join on the nearest key (backward/forward/nearest). Ideal for time-series: match trades to most recent quotes. Supports by-group matching, tolerance, allow_exact_matches, and custom suffixes. Mirrors pandas.merge_asof().

βœ… Complete

πŸ“‹ merge_ordered β€” Ordered Fill Merge

mergeOrdered β€” ordered outer/inner/left/right merge sorted by key column(s). Supports fill_method: "ffill" to forward-fill null gaps, left_by/right_by for group-wise ordered merging, left_on/right_on for different key names, and suffix handling. Mirrors pandas.merge_ordered().

βœ… Complete

πŸ“… resample β€” Time-Based Resampling

resampleSeries / resampleDataFrame β€” time-based groupby aggregation. Supports S/T/H/D/W/MS/ME/QS/QE/YS/YE frequencies, aggregations (sum, mean, min, max, count, first, last, std, var, size, ohlc), per-column agg specs, and automatic empty-bin filling. Mirrors pandas.DataFrame.resample().

βœ… Complete

πŸ” infer_objects / convert_dtypes β€” Dtype Inference

inferObjectsSeries / inferObjectsDataFrame / convertDtypesSeries / convertDtypesDataFrame β€” promote object-typed Series to better dtypes and parse string columns as numbers. Mirrors pandas infer_objects() and convert_dtypes().

βœ… Complete

πŸ§ͺ testing β€” Assertion Utilities

assertSeriesEqual / assertFrameEqual / assertIndexEqual β€” rich assertion helpers for use in test suites. Numeric tolerance, checkLike column-order mode, dtype checks, AssertionError with detailed diff messages. Mirrors pandas.testing.

βœ… Complete

⚑ Benchmarks

Side-by-side performance comparison of tsb (TypeScript/Bun) vs pandas (Python). Timing metrics for each function.

πŸ—οΈ In Progress