🗃️ DataFrame — Interactive Playground
DataFrame is the heart of tsb: a
two-dimensional, column-oriented table where every column is a typed
Series. It mirrors pandas.DataFrame with a fully
strict TypeScript API.
Edit any code block below and press ▶ Run
(or Ctrl+Enter) to execute it live in your browser.
Construction
Three factory methods cover the most common shapes of input data:
fromColumns, fromRecords, and from2D.
Properties
Inspect the shape, dimensionality, size, and axes of a DataFrame.
Column Access
Retrieve columns with col() (throws if missing),
get() (returns undefined), and check existence with has().
Slicing
Select rows by position with head(), tail(),
iloc(), or by label with loc().
Column Mutations
All mutation methods return a new
DataFrame — tsb is immutable. Use assign(), drop(),
select(), and rename().
Missing Values
Detect, drop, and fill null values across the entire DataFrame.
Aggregations
Column-wise aggregates: sum(), mean(),
min(), max(), count(), and the
all-in-one describe().
Sorting
Sort rows by column values with sortValues() or by the
index with sortIndex().
Apply & Iteration
Use apply() to run a function over columns (axis 0) or rows
(axis 1). Iterate with items() and iterrows().
Conversion
Convert between DataFrames and plain JavaScript structures.
Use setIndex() and resetIndex() to manipulate
the row index.
🧪 Try It Yourself
Write your own tsb code below. All exports from tsb are available:
DataFrame, Series, Index, Dtype, and more.