Skip to content

Tbl module

This page explains what the Tbl module is and when to use it.

The Tbl module helps you look at a table, whatever its source: a database, a file you loaded or the result of a query. It summarizes each column and returns rows from evenly spaced places, so you can see what a table holds without printing all of it.

Each function takes a table or keyed table and returns a table, so you can query, save or join the result. The module is written in q, so there is nothing to compile. It works with KDB-X 5.0 or later.

Load the module

.tbl:use`kx.tbl
.tbl.describe ([]a:1 2 0N 4;b:`x`y`x`)

Functions

Function Description
describe Returns statistics of each column of a table.
peek Returns rows of a table: the first rows, then blocks of rows from evenly spaced places in the rest of it, in the order of the table.

describe works like describe in pandas and polars, with one row for each column. The statistics include the type, the counts of values, nulls and distinct values, the mean, standard deviation and quartiles of numeric columns, the range and the most frequent value.

Use cases

The Tbl module is most useful for:

  • Checking a load. Run describe on a table you loaded with the CSV module to confirm the types and spot unexpected nulls.
  • Exploring a database. Use peek to see rows from across a large table, not only the first few.
  • Data quality checks. Compare statistics between days or sources.

Further information

Refer to the Tbl GitHub repository for: