afshin-dini commited on
Commit
b4451e2
·
1 Parent(s): 71abe0d

Add summary table

Browse files
src/ai_dashboard/table_plugin/summary_table.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Statistical Summary Table plugin"""
2
+
3
+ from typing import Any
4
+ import logging
5
+ from dash import html, dash_table
6
+ from ..base import BaseTablePlugin
7
+
8
+ logger = logging.getLogger(__name__)
9
+
10
+
11
+ class SummaryStatisticsTablePlugin(BaseTablePlugin):
12
+ """Summary statistics table (describe())."""
13
+
14
+ name = "Summary Statistics Table"
15
+
16
+ def controls(self) -> Any:
17
+ """Summary table has no controls."""
18
+ return html.Div("No controls for this table.")
19
+
20
+ def render(self, **kwargs: Any) -> Any:
21
+ """Render the summary statistics table."""
22
+ desc = self.dataframe.describe(include="all").transpose().reset_index()
23
+ desc = desc.rename(columns={"index": "Column"})
24
+
25
+ return dash_table.DataTable( # type: ignore
26
+ id="summary-stats-table",
27
+ columns=[{"name": c, "id": c} for c in desc.columns],
28
+ data=desc.to_dict("records"),
29
+ style_table={"overflowX": "auto"},
30
+ style_cell={
31
+ "textAlign": "center",
32
+ "padding": "6px",
33
+ "border": "1px solid #ccc",
34
+ "fontFamily": "Times New Roman, Times, serif",
35
+ },
36
+ style_header={
37
+ "backgroundColor": "#f0f0f0",
38
+ "fontWeight": "bold",
39
+ },
40
+ )
41
+
42
+ def register_callbacks(self, app: Any) -> Any:
43
+ """Register callbacks for the summary statistics table."""
44
+ return None