Module pandas_profiling.report.presentation.flavours.widget.frequency_table
Expand source code
from ipywidgets import widgets, GridspecLayout, VBox
from pandas_profiling.report.presentation.core.frequency_table import FrequencyTable
def get_table(items):
table = GridspecLayout(len(items), 3)
for row_id, (label, progress, count) in enumerate(items):
table[row_id, 0] = label
table[row_id, 1] = progress
table[row_id, 2] = count
return VBox([table])
class WidgetFrequencyTable(FrequencyTable):
def render(self):
items = []
for row in self.content["rows"]:
if row["extra_class"] == "missing":
items.append(
(
widgets.Label(str(row["label"])),
widgets.FloatProgress(
value=row["count"], min=0, max=row["n"], bar_style="danger"
),
widgets.Label(str(row["count"])),
)
)
elif row["extra_class"] == "other":
items.append(
(
widgets.Label(str(row["label"])),
widgets.FloatProgress(
value=row["count"], min=0, max=row["n"], bar_style="info"
),
widgets.Label(str(row["count"])),
)
)
else:
items.append(
(
widgets.Label(str(row["label"])),
widgets.FloatProgress(
value=row["count"], min=0, max=row["n"], bar_style=""
),
widgets.Label(str(row["count"])),
)
)
return get_table(items)
Functions
def get_table(items)
-
Expand source code
def get_table(items): table = GridspecLayout(len(items), 3) for row_id, (label, progress, count) in enumerate(items): table[row_id, 0] = label table[row_id, 1] = progress table[row_id, 2] = count return VBox([table])
Classes
class WidgetFrequencyTable (rows, **kwargs)
-
Helper class that provides a standard way to create an ABC using inheritance.
Expand source code
class WidgetFrequencyTable(FrequencyTable): def render(self): items = [] for row in self.content["rows"]: if row["extra_class"] == "missing": items.append( ( widgets.Label(str(row["label"])), widgets.FloatProgress( value=row["count"], min=0, max=row["n"], bar_style="danger" ), widgets.Label(str(row["count"])), ) ) elif row["extra_class"] == "other": items.append( ( widgets.Label(str(row["label"])), widgets.FloatProgress( value=row["count"], min=0, max=row["n"], bar_style="info" ), widgets.Label(str(row["count"])), ) ) else: items.append( ( widgets.Label(str(row["label"])), widgets.FloatProgress( value=row["count"], min=0, max=row["n"], bar_style="" ), widgets.Label(str(row["count"])), ) ) return get_table(items)
Ancestors
- FrequencyTable
- ItemRenderer
- Renderable
- abc.ABC
Methods
def render(self)
-
Expand source code
def render(self): items = [] for row in self.content["rows"]: if row["extra_class"] == "missing": items.append( ( widgets.Label(str(row["label"])), widgets.FloatProgress( value=row["count"], min=0, max=row["n"], bar_style="danger" ), widgets.Label(str(row["count"])), ) ) elif row["extra_class"] == "other": items.append( ( widgets.Label(str(row["label"])), widgets.FloatProgress( value=row["count"], min=0, max=row["n"], bar_style="info" ), widgets.Label(str(row["count"])), ) ) else: items.append( ( widgets.Label(str(row["label"])), widgets.FloatProgress( value=row["count"], min=0, max=row["n"], bar_style="" ), widgets.Label(str(row["count"])), ) ) return get_table(items)