Generated Reference
Everything below is generated from the source at build time, so it cannot drift from the code the way a hand-written page can. For the narrative version — what to reach for and why — see the High-Level API and the Configuration Guide.
Entry points
pysuricata.profile(data, config=None, *, preset=None, **options)
Compute statistics and render a self‑contained HTML report.
The function accepts in‑memory data (pandas or polars) or an iterable of pandas or polars chunks. Both pandas and polars DataFrames are processed consistently - chunking is handled by the engine based on the chunk_size configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataLike
|
Dataset to analyze. Supported:
- The last three stream a batch at a time and are never materialised as a whole frame. See the Arrow, Parquet and DuckDB guide. |
required |
config
|
ProfileConfig | None
|
Optional configuration overriding compute/render defaults.
Set chunk_size=None to disable chunking for both pandas and polars.
This is the full escape hatch and cannot be combined with |
None
|
preset
|
str | None
|
|
None
|
**options
|
Any
|
The most-reached-for settings, without the nesting:
|
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
A |
Report
|
class: |
Report
|
mapping. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If |
ConfigurationError
|
If an option or preset is not recognised, or
|
Examples:
>>> profile(df)
>>> profile(df, chunk_size=50_000, correlations=False)
>>> profile(df, preset="fast")
Source code in pysuricata/api.py
1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 | |
pysuricata.summarize(data, config=None, *, preset=None, **options)
Compute statistics only and return a JSON‑safe mapping.
This is the programmatic counterpart to :func:profile for code paths that
do not need the HTML report (e.g., CI checks and data quality gates).
Both pandas and polars DataFrames are processed consistently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataLike
|
Dataset to analyze. Same accepted types as :func: |
required |
config
|
ProfileConfig | None
|
Optional configuration overriding compute/render defaults.
Cannot be combined with |
None
|
preset
|
str | None
|
|
None
|
**options
|
Any
|
Same keyword options as :func: |
{}
|
Returns:
| Type | Description |
|---|---|
Mapping[str, Any]
|
A nested mapping with dataset‑level and per‑column statistics. The |
Mapping[str, Any]
|
result is safe to serialize to JSON. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If |
ConfigurationError
|
If an option or preset is not recognised. |
Source code in pysuricata/api.py
pysuricata.compare(before, after, *, seed=0, **options)
Compare two datasets and report what changed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
before
|
Any
|
The reference. A DataFrame, a path, an Arrow or DuckDB source,
or a |
required |
after
|
Any
|
The dataset to compare against it, in any of the same forms. |
required |
seed
|
int
|
Passed to |
0
|
**options
|
Any
|
Any other keyword |
{}
|
Returns:
| Type | Description |
|---|---|
Comparison
|
The comparison. |
Example
Source code in pysuricata/comparison.py
Configuration
pysuricata.ProfileConfig
dataclass
High-level configuration for data profiling.
This is the main configuration class used by the public API functions
profile() and summarize(). It contains compute and render options
that control how data is processed and how the output is generated.
Examples:
Basic usage with defaults
config = ProfileConfig()
Custom compute settings
config = ProfileConfig( compute=ComputeOptions( chunk_size=100_000, numeric_sample_size=10_000, random_seed=42 ) )
Attributes:
| Name | Type | Description |
|---|---|---|
compute |
ComputeOptions
|
Compute-related options; see :class: |
render |
RenderOptions
|
Render-related options; see :class: |
Source code in pysuricata/api.py
pysuricata.ComputeOptions
dataclass
Configuration for data processing and analysis.
These options control how data is streamed and how approximations are performed during computation. They are intentionally conservative by default to provide stable results for small to medium datasets, while still scaling to larger ones.
Examples:
For large datasets (memory constrained)
ComputeOptions(chunk_size=50_000, numeric_sample_size=5_000)
For high-quality analysis
ComputeOptions(chunk_size=500_000, numeric_sample_size=50_000)
For reproducible results
ComputeOptions(random_seed=42)
For specific columns only
ComputeOptions(columns=["age", "income", "education"])
With checkpointing for large datasets
ComputeOptions( chunk_size=100_000, checkpoint_every_n_chunks=10, checkpoint_dir="./checkpoints", checkpoint_write_html=True )
Attributes:
| Name | Type | Description |
|---|---|---|
chunk_size |
int | None
|
Number of rows to process in each chunk. Default: 50,000. Bigger is not faster: the sketch merges are superlinear in batch size, so one 200,000-row batch costs more than four 50,000-row ones. Raise it only to trade memory for fewer chunk boundaries. |
columns |
Sequence[str] | None
|
Optional subset of columns to analyze. If None, all columns are analyzed. Default: None (all columns) |
numeric_sample_size |
int
|
Reservoir sample size for numeric statistics like quantiles and histograms. Larger samples give better accuracy but use more memory. Default: 20,000 |
max_uniques |
int
|
Sketch size for approximate unique value counting. Larger sketches give better accuracy but use more memory. Default: 2,048 |
top_k |
int
|
Maximum number of top categories to track for categorical columns. Default: 50 |
random_seed |
int | None
|
Seed for reproducible sampling. Set to None for non-deterministic results. Default: 0 -- reproducible unless you ask for otherwise, so re-running the same data is a no-op. |
progress |
Any
|
Whether to report progress while streaming. True, False, "auto" (report only when stderr is a terminal) or a callable taking chunks/rows/elapsed. Always stderr, never stdout, so piped output stays parseable. Default: False |
log_every_n_chunks |
int
|
Log progress every N chunks. Set to 1 to log every chunk, higher values for less frequent logging. Default: 1 |
checkpoint_every_n_chunks |
int
|
Create checkpoint every N chunks. Set to 0 to disable checkpointing. Default: 0 (disabled) |
checkpoint_dir |
str | None
|
Directory for checkpoint files. If None, uses current working directory. Default: None |
checkpoint_prefix |
str
|
Prefix for checkpoint filenames. Default: "pysuricata_ckpt" |
checkpoint_write_html |
bool
|
Whether to include HTML in checkpoints. Default: False |
checkpoint_max_to_keep |
int
|
Maximum number of checkpoints to retain. Default: 3 |
enable_auto_boolean_detection |
bool
|
Whether to automatically detect 0/1 numeric columns as boolean. Default: True |
boolean_detection_min_samples |
int
|
Minimum number of samples required for boolean detection. Default: 100 |
boolean_detection_max_zero_ratio |
float
|
Maximum ratio of zeros allowed for boolean detection (to avoid classifying mostly-zero columns as boolean). Default: 0.80 |
boolean_detection_require_name_pattern |
bool
|
Whether to require boolean-like column names (e.g., 'is_', 'has_', 'can_') for detection. Default: False, so a 0/1 column is detected on its values whatever it is called. |
force_column_types |
dict[str, str] | None
|
Optional dictionary mapping column names to their forced types. Overrides automatic type inference. Default: None |
compute_correlations |
bool
|
Whether to compute pairwise correlations between numeric columns. Default: True |
corr_threshold |
float
|
Minimum absolute correlation value to report. Only correlations with |r| >= threshold are shown. Default: 0.5 |
corr_max_cols |
int
|
Maximum number of numeric columns for correlation analysis. If exceeded, correlations are skipped. Default: 50 |
corr_max_per_col |
int
|
Maximum number of top correlations to show per column. Default: 10 |
Source code in pysuricata/api.py
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 | |
checkpoint
property
The five checkpointing settings as one named group.
A view rather than a nested dataclass: the fields stay where they are,
so nothing existing breaks, while options.checkpoint.every_n_chunks
gives the concern a name and keeps it out of the way of the settings
people actually reach for.
validate()
Check every invariant, from wherever the options are about to be used.
This is called at construction and again when the options are handed to the engine, because the dataclass is mutable and the second path is the one people take:
ComputeOptions(chunk_size=0) # ValueError: chunk_size must be positive
c = ComputeOptions()
c.chunk_size = 0 # accepted, and profiled happily
The constructor guarded a door nobody walks through. Two rules for one field is also the class of inconsistency that produces a bug report you cannot reproduce, so there is now one rule, called from both places.
Raises:
| Type | Description |
|---|---|
ValueError
|
If a value is outside its documented range. |
ConfigurationError
|
If |
Source code in pysuricata/api.py
pysuricata.RenderOptions
dataclass
Render options for the HTML output.
The current HTML report is self-contained and styled with built-in assets. This class controls various rendering aspects of the report.
Attributes:
| Name | Type | Description |
|---|---|---|
title |
str | None
|
Optional custom title for the HTML report. If not provided, defaults to "PySuricata EDA Report". This title appears in both the browser tab and the main heading of the report. |
description |
str | None
|
Optional user description to display in the summary section. If provided, this will be shown below the "Summary" heading with consistent styling. Can be used to provide context about the dataset or analysis. |
include_sample |
bool
|
Whether the report shows a handful of sample rows. Default: True. It removes the sample table, and only the sample table. Raw values still reach the page from four other places: a categorical card's top-value labels and its shortest/longest exemplars, and the numeric and datetime extremes. This is not a redaction switch, and the docs no longer describe it as one (#285). |
sample_rows |
int
|
How many rows the sample shows, when it is shown. Default: 10. |
Source code in pysuricata/api.py
Results
pysuricata.Report
dataclass
Source code in pysuricata/api.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | |
save(path)
Save the report based on the file extension.
If the extension is .html, the HTML is written. If it is .json,
the stats mapping is written as JSON.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Destination file path. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the extension is not one of |
Source code in pysuricata/api.py
save_html(path)
Write the HTML report to disk.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Destination file path. Parent directories must exist. |
required |
save_json(path)
Write the statistics mapping to a JSON file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Destination file path. Parent directories must exist. |
required |
Source code in pysuricata/api.py
show(width='100%', height='600px')
display_in_notebook(width='100%', height='600px')
Display the report in a Jupyter notebook using an iframe.
This method provides better display for large reports in Jupyter notebooks by using an iframe instead of inline HTML.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
width
|
str
|
Width of the iframe (default: "100%") |
'100%'
|
height
|
str
|
Height of the iframe (default: "600px") |
'600px'
|
Source code in pysuricata/api.py
pysuricata.Comparison
dataclass
The full diff between two datasets.
Attributes:
| Name | Type | Description |
|---|---|---|
dataset |
DatasetDelta
|
Whole-frame movement. |
schema |
SchemaDelta
|
Columns added, removed and retyped. |
columns |
dict[str, ColumnDelta]
|
Per-column deltas, for columns present in both. |
Source code in pysuricata/comparison.py
to_dict()
A JSON-serialisable view.
Source code in pysuricata/comparison.py
Errors
pysuricata.PySuricataError
Bases: Exception
Base class for every error this library raises deliberately.
The public surface used to raise TypeError for an unsupported input,
ValueError for an unsupported file format and RuntimeError from the
engine for the same class of mistake, so a caller had to catch three types
to handle one situation. Everything raised on purpose now derives from this;
the specific types remain as subclasses so existing except TypeError
handlers keep working.
pysuricata.UnsupportedDataError
Bases: PySuricataError, TypeError
The input is not something this library can profile.
pysuricata.ConfigurationError
Bases: PySuricataError, ValueError
A configuration value is outside its documented range.
Readers
The batch readers behind the path, Arrow and DuckDB inputs, for when you want the batches rather than a profile.
pysuricata.sources
Stream Arrow, Parquet and DuckDB without materialising them first.
Every source used to arrive as a pandas or polars frame, which for a Parquet file or a DuckDB query meant reading the whole thing into memory before profiling it. That contradicts the one claim the library is positioned on -- bounded memory regardless of dataset size -- for exactly the inputs where the claim matters most.
The engine already consumes an iterable of chunks, so this is a reader per source rather than a change to the core. All three arrive as Arrow record batches, so there is really one reader and two entry points.
What this is not. The accumulators take numpy arrays, so each batch is converted on its way through; this is not a zero-copy Arrow path. What changes is that one batch is materialised at a time instead of the entire file.
One behavioural consequence, stated up front. Type inference reclassifies a
numeric column as categorical from the distinct values it can see, which is
sound evidence only when the whole column is in hand. A stream cannot offer
that: a leading run of one value looks low-cardinality while the column is not.
So a file that arrives in a single batch is handed to the engine as a frame --
identical results to pd.read_parquet -- and a file that does not is treated as
what it is, a stream.
stream_parquet(path, *, batch_size=None, columns=None)
Yield a Parquet file one batch at a time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | PathLike
|
Path to a |
required |
batch_size
|
int | None
|
Rows per batch. Defaults to |
None
|
columns
|
list[str] | None
|
Optional subset to read. Columns not read are never decoded, which is where most of the saving is on a wide file. |
None
|
Yields:
| Type | Description |
|---|---|
DataFrame
|
One pandas DataFrame per batch. |
Raises:
| Type | Description |
|---|---|
ImportError
|
If pyarrow is not installed. |
FileNotFoundError
|
If the file does not exist. |
Source code in pysuricata/sources.py
stream_ipc(path, *, batch_size=None)
Yield an Arrow IPC file one batch at a time.
This is the format another runtime writes -- arrow::write_ipc_file() in
R, Arrow.write() in Julia, the arrow crate in Rust -- which is what
makes it worth reading directly rather than through a conversion (#247).
Three different framings can wear these extensions, and the extension
does not say which. Dispatching on the suffix would load an R
write_ipc_file() and fail on an Arrow.write(), since Julia defaults to
the stream framing. So the first bytes decide:
| magic | framing | read by |
|---|---|---|
ARROW1 |
IPC file, with a footer | pa.ipc.open_file |
ÿÿÿÿ |
IPC stream, no footer | pa.ipc.open_stream |
FEA1 |
Feather V1, not IPC at all | feather.read_table |
Only the last materialises, and that format is legacy -- pyarrow itself deprecated writing it in 25.0.0 -- so it has no streaming reader to use.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | PathLike
|
Path to a |
required |
batch_size
|
int | None
|
Rows per batch, where the framing lets us choose. The two IPC framings carry the batching their writer chose and are read as they were written. |
None
|
Yields:
| Type | Description |
|---|---|
DataFrame
|
One pandas DataFrame per batch. |
Raises:
| Type | Description |
|---|---|
ImportError
|
If pyarrow is not installed. |
FileNotFoundError
|
If the file does not exist. |
Source code in pysuricata/sources.py
stream_arrow(source, *, batch_size=None)
Yield an Arrow source one batch at a time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
Any
|
A |
required |
batch_size
|
int | None
|
Rows per batch, where the source lets us choose. A
|
None
|
Yields:
| Type | Description |
|---|---|
DataFrame
|
One pandas DataFrame per batch. |
Raises:
| Type | Description |
|---|---|
ImportError
|
If pyarrow is not installed. |
TypeError
|
If the object is not an Arrow source. |
Source code in pysuricata/sources.py
stream_duckdb(relation, *, batch_size=None)
Yield a DuckDB relation or query result one batch at a time.
A relation is a query that has not run yet, so this profiles a result set without ever landing it in memory:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
relation
|
Any
|
A DuckDB relation or result — anything with
|
required |
batch_size
|
int | None
|
Rows per batch. |
None
|
Yields:
| Type | Description |
|---|---|
DataFrame
|
One pandas DataFrame per batch. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the object cannot produce Arrow batches. |
Source code in pysuricata/sources.py
is_arrow_source(obj)
Whether stream_arrow can read this object.
Two ways to qualify. A pyarrow object is recognised by module name, without
importing pyarrow — an import inside a type check would make every
profile() call pay for a dependency the caller may not have. Anything
else qualifies by exporting __arrow_c_stream__, the Arrow PyCapsule
interface, which is how the rest of the ecosystem hands data over without
anyone agreeing on a type.
pandas and polars are excluded explicitly rather than by being checked first somewhere else: both export the capsule (pandas since 2.2), both have their own adapter, and a predicate that is only correct because of the order its caller happens to use it in is a trap for the next caller.
Source code in pysuricata/sources.py
is_duckdb_relation(obj)
Whether stream_duckdb can read this object.
Duck-typed on the batch-reader method, which is specific enough to be safe
and survives DuckDB moving its classes between modules -- they live in
_duckdb rather than duckdb, which a module-name check gets wrong.