Skip to content

Conversation

@Subat-01
Copy link

@Subat-01 Subat-01 commented Oct 17, 2025

Background

Table.hist needed clearer documentation and safer behavior for the group argument.

Changes

Code

  • datascience/tables.py:hist
    • Validate group is a legal column (label or index); otherwise raise ValueError with a clear message.
    • Keep existing constraints: group cannot be used with bin_column; and grouping allows only one numeric data column.
    • When the grouped subset is empty, return an empty figure safely (avoid exceptions).
    • Expanded docstring with two examples:
      • t.hist('height', group='gender')
      • t.hist('height', group='gender', side_by_side=True)

Docs

  • New docs/hist_grouping.md:
    • Minimal example and explanation of constraints + empty-data behavior.
    • (If the project prefers RST/toctree only, I'm happy to convert to .rst and add it to the TOC.)

Tests

  • tests/test_hist_group.py
    • Valid grouping runs without error.
    • Non-existent group column raises ValueError.
    • Empty grouped subset renders safely (creates an empty plot).

(Optional) Maps small fixes

  • datascience/maps.py
    • Provide default attribution when a string tile style is used and no attr supplied (Folium >= 0.20).
    • Mirror text_color -> textColor option for BeautifyIcon for backward compatibility.

Verification

  • Local run: 225 passed, 1 skipped, 0 failed.

Files changed (for quick review)

  • datascience/tables.py [around lines ~5310, ~5398, ~5420, ~5455]
  • docs/hist_grouping.md
  • tests/test_hist_group.py
  • (optional) datascience/maps.py

Compatibility & Notes

  • No breaking API changes; clearer errors, docs, and tests.
  • Open to adjusting error types/doc placement or dropping the maps tweak if maintainers prefer a focused PR.

…and empty-group handling; add tests; fix folium tile attribution and BeautifyIcon textColor compatibility
@Subat-01 Subat-01 changed the title docs(hist): document group usage with examples; add group validation … hist(group): add validation & empty-data handling; docstring, guide and tests Oct 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants