CtrlK
CommunityDocumentationLog inGet started
Tessl Logo

tessl/pypi-tabulate

tessl install tessl/pypi-tabulate@0.9.0

Pretty-print tabular data in Python with extensive formatting options and output format support.

Agent Success

Agent success rate when using this tile

69%

Improvement

Agent success rate improvement when using this tile compared to baseline

0.9x

Baseline

Agent success rate without this tile

77%

task.mdevals/scenario-10/

Data Report Generator with Missing Value Handling

Build a Python program that generates formatted reports from datasets containing incomplete data. The program should handle missing values appropriately when creating tables.

Requirements

Your program should read data from CSV files and generate formatted table reports that:

  1. Handle missing values in datasets: Replace missing/null values with appropriate placeholder text when displaying tables
  2. Support different placeholder strategies:
    • Use a default placeholder (e.g., "N/A") for all missing values
    • Allow column-specific placeholders when different columns need different missing value representations
  3. Generate clean table output: Produce well-formatted tables suitable for reports

Input Format

The program will read CSV files where some cells may be empty (representing missing data). For example:

Name,Age,Department,Salary
Alice,30,Engineering,75000
Bob,,Marketing,
Charlie,45,Engineering,85000
Dana,28,,62000

Output Requirements

The program should output a formatted table that:

  • Displays all data in a readable table format
  • Replaces empty/missing values with meaningful placeholders
  • Maintains proper alignment and formatting

Test Cases

Test Case 1: Basic missing value replacement

Input CSV (employees_basic.csv):

Name,Score
Alice,95
Bob,
Charlie,87

Expected behavior:

  • All missing values should be replaced with "N/A"
  • The table should display three rows with proper formatting
  • Missing score for Bob should appear as "N/A"

@test

Test Case 2: Column-specific missing value placeholders

Input CSV (employees_detailed.csv):

Name,Age,Salary
Alice,30,75000
Bob,,50000
Charlie,35,

Expected behavior:

  • Missing age values should be replaced with "Unknown"
  • Missing salary values should be replaced with "Confidential"
  • Each column should use its appropriate placeholder

@test

Implementation

@generates

API

def generate_report(csv_file_path: str, missing_placeholder: str = "N/A") -> str:
    """
    Generate a formatted table report from a CSV file with missing value handling.

    Args:
        csv_file_path: Path to the CSV file to process
        missing_placeholder: Placeholder text for missing values (default: "N/A")

    Returns:
        A formatted table as a string
    """
    pass

def generate_report_with_column_placeholders(
    csv_file_path: str,
    column_placeholders: dict
) -> str:
    """
    Generate a formatted table report with column-specific missing value placeholders.

    Args:
        csv_file_path: Path to the CSV file to process
        column_placeholders: Dictionary mapping column names to their placeholder text
                           e.g., {"Age": "Unknown", "Salary": "Confidential"}

    Returns:
        A formatted table as a string
    """
    pass

Dependencies { .dependencies }

tabulate { .dependency }

Provides table formatting functionality with support for handling missing values.

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/tabulate@0.9.x
tile.json