Spaces:
Sleeping
Sleeping
| """Statistical Summary Table plugin""" | |
| from typing import Any | |
| import logging | |
| from dash import html, dash_table | |
| from ..base import BaseTablePlugin | |
| logger = logging.getLogger(__name__) | |
| class SummaryStatisticsTablePlugin(BaseTablePlugin): | |
| """Summary statistics table (describe()).""" | |
| name = "Summary Statistics Table" | |
| def controls(self) -> Any: | |
| """Summary table has no controls.""" | |
| return html.Div("No controls for this table.") | |
| def render(self, **kwargs: Any) -> Any: | |
| """Render the summary statistics table.""" | |
| desc = self.dataframe.describe(include="all").transpose().reset_index() | |
| desc = desc.rename(columns={"index": "Column"}) | |
| return dash_table.DataTable( # type: ignore | |
| id="summary-stats-table", | |
| columns=[{"name": c, "id": c} for c in desc.columns], | |
| data=desc.to_dict("records"), | |
| style_table={"overflowX": "auto"}, | |
| style_cell={ | |
| "textAlign": "center", | |
| "padding": "6px", | |
| "border": "1px solid #ccc", | |
| "fontFamily": "Times New Roman, Times, serif", | |
| }, | |
| style_header={ | |
| "backgroundColor": "#f0f0f0", | |
| "fontWeight": "bold", | |
| }, | |
| ) | |
| def register_callbacks(self, app: Any) -> Any: | |
| """Register callbacks for the summary statistics table.""" | |
| return None | |