Skip to content

Implementing Phase 3 for summary() #8

Description

@kengggg

@notskynet-bot

Phase 3: summary() — Requirements

  • Add epydem.summary(df, by=None, date_cols=None, numeric_cols=None, categorical_cols=None, top_k=3, output="long") -> pd.DataFrame

  • Conservative defaults (strict):

    • If date_cols, numeric_cols, and categorical_cols are all None/empty => return only n (respecting by)
    • Do not infer columns automatically
  • Metrics:

    • n per group
    • Missingness per specified column: missing_n, missing_pct
    • Date cols: min, max after pd.to_datetime(..., errors="coerce") (invalid -> missing)
    • Numeric cols: count, mean, std, min, p25, median, p75, max
    • Categorical cols: top_1..top_k and top_#_n
      • deterministic tie-break: count desc, then string(value) asc
      • missing token: <NA>
  • Output:

    • default output="long" schema: by..., column, metric, value
    • optional output="wide" pivots metrics into columns (index includes by... + column)
  • Tests:

    • by vs no-by
    • default-only-n behavior
    • date coercion behavior
    • numeric quartiles
    • categorical tie-breaking
  • Docs: add README example(s) for summary()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions