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.
π merge
SQL-style DataFrame joins. inner/left/right/outer, on/left_on/right_on, suffixes.
π‘ str accessor
Vectorised string operations. lower/upper/strip/pad/contains/replace/split/extract & predicates.
π dt accessor
Vectorised datetime operations. Calendar components, boolean boundaries, strftime, floor/ceil/round.
π describe
Summary statistics. count/mean/std/min/percentiles/max for numeric; count/unique/top/freq for categorical. Series.quantile().
π₯ I/O
CSV I/O. readCsv / toCsv with dtype inference, NA handling, quoted fields, custom separators.
π₯ JSON I/O
JSON I/O. readJson / toJson with five orient formats: records, split, index, columns, values.
π corr & cov
Pearson correlation & covariance. Series.corr(), DataFrame.corr(), DataFrame.cov(), dataFrameCorr(), dataFrameCov() with index alignment, null handling, and configurable ddof/minPeriods.
πͺ rolling
Sliding-window aggregations. Series.rolling() and DataFrame.rolling() with mean, sum, std, var, min, max, count, median, apply. Supports minPeriods and centered windows.
π 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.
π·οΈ cat accessor
Categorical operations. Series.cat with categories, codes, ordered, addCategories, removeCategories, renameCategories, setCategories, reorderCategories, valueCounts.
π 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.
π melt
Wide-to-long reshape. Unpivot columns into variable/value pairs with id_vars, value_vars, var_name, value_name.
π 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.
π 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.
π 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.
π 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.
π cumulative operations
Compute running totals, products, maxima, and minima. cumsum(), cumprod(), cummax(), cummin() for Series and DataFrame with skipna support and axis=0/1.
βοΈ element-wise ops
Element-wise transformations. clip(), seriesAbs(), seriesRound() for Series and DataFrame with min/max bounds, decimal precision, and axis support.
π’ value_counts
Count unique values. valueCounts() for Series and dataFrameValueCounts() for DataFrame with normalize, sort, ascending, and dropna options.
ποΈ MultiIndex
Hierarchical indexing. MultiIndex for multi-level row and column labels with fromArrays, fromTuples, fromProduct, level access, and swapLevels.
π₯ 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().
βοΈ 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.
π 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().
π§ 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().
π 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.
π 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.
π 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.
π·οΈ 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.
π€ 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.
π€ 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.
π 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).
π’ 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.
π·οΈ categorical_ops β Categorical Utilities
Standalone categorical helpers: catFromCodes (from integer codes), set operations (catUnionCategories, catIntersectCategories, catDiffCategories, catEqualCategories), catSortByFreq, catToOrdinal, catFreqTable, catCrossTab, catRecode.
π’ 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.
π 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.
π 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.
π 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.
π’ 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.
β±οΈ 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.
β³ 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.
π 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.
π 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.
βοΈ 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.
βοΈ between β Range Check
seriesBetween β element-wise range check returning a boolean Series. Mirrors pandas Series.between(). Supports inclusive="both"|"left"|"right"|"neither".
π 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().
π½ filter β Filter Labels
filterDataFrame / filterSeries β filter rows or columns by label using items list, substring (like), or regex pattern. Mirrors pandas DataFrame.filter().
π 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().
β keepTrue / keepFalse / filterBy β Boolean Indexing
keepTrue / keepFalse / filterBy β boolean-mask selection helpers for Series and DataFrames. Mirrors pandas boolean indexing (series[mask], df[mask]).
π’ 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().
π 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().
π 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().
β±οΈ 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().
π 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().
π 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().
π 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().
π§ͺ 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.
β‘ Benchmarks
Side-by-side performance comparison of tsb (TypeScript/Bun) vs pandas (Python). Timing metrics for each function.