Format Statistics Table

by jimmc414

skill

For result reporting: tabular output, aligned columns, statistics summaries, human-readable reports.

Skill Details

Repository Files

1 file in this skill directory


name: format-statistics-table description: "For result reporting: tabular output, aligned columns, statistics summaries, human-readable reports."

format-statistics-table

When to Use

  • Reporting test results
  • Showing statistics
  • Comparing alternatives
  • Human inspection of data

When NOT to Use

  • Machine-parseable output (use JSON/CSV)
  • Simple single values
  • Too many columns

The Pattern

Format data as aligned columns with headers and separators.

def print_table(headers, rows, widths=None):
    """Print formatted table."""
    if widths is None:
        widths = [max(len(str(row[i])) for row in [headers] + rows)
                  for i in range(len(headers))]

    # Header
    print(' | '.join(h.ljust(w) for h, w in zip(headers, widths)))
    print('-+-'.join('-' * w for w in widths))

    # Rows
    for row in rows:
        print(' | '.join(str(v).ljust(w) for v, w in zip(row, widths)))

Example (from pytudes)

# SET.py - game statistics
def show(tallies, label):
    """Print out the counts."""
    print()
    print('Size |  Sets  | NoSets | Set:NoSet ratio for', label)
    print('-----+--------+--------+----------------')
    for size in sorted(tallies):
        y, n = tallies[size][True], tallies[size][False]
        ratio = ('inft' if n == 0 else int(round(float(y) / n)))
        print('{:4d} |{:7,d} |{:7,d} | {:4}:1'
              .format(size, y, n, ratio))

# Output:
# Size |  Sets  | NoSets | Set:NoSet ratio for random
# -----+--------+--------+----------------
#    3 |    100 |      0 | inft:1
#    4 |    200 |     50 |    4:1
#    5 |    400 |    100 |    4:1

# sudoku.py - solve statistics
def solve_all(grids, name=''):
    """Report solution statistics."""
    times, results = zip(*[time_solve(grid) for grid in grids])
    N = len(results)
    if N > 1:
        print("Solved %d of %d %s puzzles "
              "(avg %.2f secs (%d Hz), max %.2f secs)." % (
            sum(results), N, name,
            sum(times)/N, N/sum(times), max(times)))

# Output:
# Solved 50 of 50 easy puzzles (avg 0.01 secs (100 Hz), max 0.03 secs).

# spell.py - accuracy reporting
print('{:.0%} of {} correct ({:.0%} unknown) at {:.0f} words per second'
      .format(good/n, n, unknown/n, n/dt))

# Output:
# 74% of 270 correct (6% unknown) at 41 words per second

Key Principles

  1. Align columns: Consistent widths
  2. Format numbers: Commas, percentages, decimals
  3. Headers and separators: Visual structure
  4. Edge cases: Handle zero, infinity
  5. Named columns: Clear what each represents

Related Skills

Attack Tree Construction

Build comprehensive attack trees to visualize threat paths. Use when mapping attack scenarios, identifying defense gaps, or communicating security risks to stakeholders.

skill

Grafana Dashboards

Create and manage production Grafana dashboards for real-time visualization of system and application metrics. Use when building monitoring dashboards, visualizing metrics, or creating operational observability interfaces.

skill

Matplotlib

Foundational plotting library. Create line plots, scatter, bar, histograms, heatmaps, 3D, subplots, export PNG/PDF/SVG, for scientific visualization and publication figures.

skill

Scientific Visualization

Create publication figures with matplotlib/seaborn/plotly. Multi-panel layouts, error bars, significance markers, colorblind-safe, export PDF/EPS/TIFF, for journal-ready scientific plots.

skill

Seaborn

Statistical visualization. Scatter, box, violin, heatmaps, pair plots, regression, correlation matrices, KDE, faceted plots, for exploratory analysis and publication figures.

skill

Shap

Model interpretability and explainability using SHAP (SHapley Additive exPlanations). Use this skill when explaining machine learning model predictions, computing feature importance, generating SHAP plots (waterfall, beeswarm, bar, scatter, force, heatmap), debugging models, analyzing model bias or fairness, comparing models, or implementing explainable AI. Works with tree-based models (XGBoost, LightGBM, Random Forest), deep learning (TensorFlow, PyTorch), linear models, and any black-box model

skill

Pydeseq2

Differential gene expression analysis (Python DESeq2). Identify DE genes from bulk RNA-seq counts, Wald tests, FDR correction, volcano/MA plots, for RNA-seq analysis.

skill

Query Writing

For writing and executing SQL queries - from simple single-table queries to complex multi-table JOINs and aggregations

skill

Pydeseq2

Differential gene expression analysis (Python DESeq2). Identify DE genes from bulk RNA-seq counts, Wald tests, FDR correction, volcano/MA plots, for RNA-seq analysis.

skill

Scientific Visualization

Meta-skill for publication-ready figures. Use when creating journal submission figures requiring multi-panel layouts, significance annotations, error bars, colorblind-safe palettes, and specific journal formatting (Nature, Science, Cell). Orchestrates matplotlib/seaborn/plotly with publication styles. For quick exploration use seaborn or plotly directly.

skill

Skill Information

Category:Skill
Last Updated:12/27/2025