polars-data-profiling 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- polars_data_profiling/__init__.py +19 -0
- polars_data_profiling/compare_reports.py +386 -0
- polars_data_profiling/config.py +558 -0
- polars_data_profiling/config_default.yaml +219 -0
- polars_data_profiling/config_minimal.yaml +218 -0
- polars_data_profiling/controller/__init__.py +1 -0
- polars_data_profiling/controller/console.py +127 -0
- polars_data_profiling/controller/namespace.py +38 -0
- polars_data_profiling/model/__init__.py +5 -0
- polars_data_profiling/model/alerts.py +779 -0
- polars_data_profiling/model/correlations.py +332 -0
- polars_data_profiling/model/dataframe.py +24 -0
- polars_data_profiling/model/describe.py +197 -0
- polars_data_profiling/model/description.py +106 -0
- polars_data_profiling/model/duplicates.py +64 -0
- polars_data_profiling/model/engine.py +192 -0
- polars_data_profiling/model/expressions.py +215 -0
- polars_data_profiling/model/handler.py +84 -0
- polars_data_profiling/model/images.py +179 -0
- polars_data_profiling/model/missing.py +161 -0
- polars_data_profiling/model/pairwise.py +59 -0
- polars_data_profiling/model/probe.py +217 -0
- polars_data_profiling/model/sample.py +77 -0
- polars_data_profiling/model/summaries.py +641 -0
- polars_data_profiling/model/summarizer.py +177 -0
- polars_data_profiling/model/summary.py +143 -0
- polars_data_profiling/model/summary_algorithms.py +301 -0
- polars_data_profiling/model/table.py +47 -0
- polars_data_profiling/model/timeseries.py +312 -0
- polars_data_profiling/model/timeseries_index.py +48 -0
- polars_data_profiling/model/type_rules.py +35 -0
- polars_data_profiling/model/typeset.py +262 -0
- polars_data_profiling/model/typeset_base.py +367 -0
- polars_data_profiling/model/typeset_relations.py +132 -0
- polars_data_profiling/profile_report.py +508 -0
- polars_data_profiling/py.typed +0 -0
- polars_data_profiling/report/__init__.py +5 -0
- polars_data_profiling/report/formatters.py +344 -0
- polars_data_profiling/report/presentation/__init__.py +1 -0
- polars_data_profiling/report/presentation/core/__init__.py +43 -0
- polars_data_profiling/report/presentation/core/alerts.py +18 -0
- polars_data_profiling/report/presentation/core/collapse.py +25 -0
- polars_data_profiling/report/presentation/core/container.py +51 -0
- polars_data_profiling/report/presentation/core/correlation_table.py +21 -0
- polars_data_profiling/report/presentation/core/dropdown.py +45 -0
- polars_data_profiling/report/presentation/core/duplicate.py +16 -0
- polars_data_profiling/report/presentation/core/frequency_table.py +14 -0
- polars_data_profiling/report/presentation/core/frequency_table_small.py +16 -0
- polars_data_profiling/report/presentation/core/html.py +14 -0
- polars_data_profiling/report/presentation/core/image.py +34 -0
- polars_data_profiling/report/presentation/core/item_renderer.py +16 -0
- polars_data_profiling/report/presentation/core/renderable.py +42 -0
- polars_data_profiling/report/presentation/core/root.py +36 -0
- polars_data_profiling/report/presentation/core/sample.py +29 -0
- polars_data_profiling/report/presentation/core/scores.py +33 -0
- polars_data_profiling/report/presentation/core/table.py +27 -0
- polars_data_profiling/report/presentation/core/toggle_button.py +14 -0
- polars_data_profiling/report/presentation/core/variable.py +51 -0
- polars_data_profiling/report/presentation/core/variable_info.py +36 -0
- polars_data_profiling/report/presentation/flavours/__init__.py +9 -0
- polars_data_profiling/report/presentation/flavours/flavour_html.py +65 -0
- polars_data_profiling/report/presentation/flavours/flavour_widget.py +62 -0
- polars_data_profiling/report/presentation/flavours/flavours.py +42 -0
- polars_data_profiling/report/presentation/flavours/html/__init__.py +57 -0
- polars_data_profiling/report/presentation/flavours/html/alerts.py +10 -0
- polars_data_profiling/report/presentation/flavours/html/collapse.py +7 -0
- polars_data_profiling/report/presentation/flavours/html/container.py +85 -0
- polars_data_profiling/report/presentation/flavours/html/correlation_table.py +21 -0
- polars_data_profiling/report/presentation/flavours/html/dropdown.py +7 -0
- polars_data_profiling/report/presentation/flavours/html/duplicate.py +23 -0
- polars_data_profiling/report/presentation/flavours/html/frame_table.py +61 -0
- polars_data_profiling/report/presentation/flavours/html/frequency_table.py +20 -0
- polars_data_profiling/report/presentation/flavours/html/frequency_table_small.py +15 -0
- polars_data_profiling/report/presentation/flavours/html/html.py +6 -0
- polars_data_profiling/report/presentation/flavours/html/image.py +7 -0
- polars_data_profiling/report/presentation/flavours/html/root.py +15 -0
- polars_data_profiling/report/presentation/flavours/html/sample.py +17 -0
- polars_data_profiling/report/presentation/flavours/html/scores.py +12 -0
- polars_data_profiling/report/presentation/flavours/html/table.py +7 -0
- polars_data_profiling/report/presentation/flavours/html/templates/alerts/alert_constant.html +1 -0
- polars_data_profiling/report/presentation/flavours/html/templates/alerts/alert_constant_length.html +1 -0
- polars_data_profiling/report/presentation/flavours/html/templates/alerts/alert_dirty_category.html +1 -0
- polars_data_profiling/report/presentation/flavours/html/templates/alerts/alert_duplicates.html +1 -0
- polars_data_profiling/report/presentation/flavours/html/templates/alerts/alert_empty.html +1 -0
- polars_data_profiling/report/presentation/flavours/html/templates/alerts/alert_high_cardinality.html +1 -0
- polars_data_profiling/report/presentation/flavours/html/templates/alerts/alert_high_correlation.html +4 -0
- polars_data_profiling/report/presentation/flavours/html/templates/alerts/alert_imbalance.html +1 -0
- polars_data_profiling/report/presentation/flavours/html/templates/alerts/alert_infinite.html +1 -0
- polars_data_profiling/report/presentation/flavours/html/templates/alerts/alert_missing.html +1 -0
- polars_data_profiling/report/presentation/flavours/html/templates/alerts/alert_near_duplicates.html +1 -0
- polars_data_profiling/report/presentation/flavours/html/templates/alerts/alert_non_stationary.html +1 -0
- polars_data_profiling/report/presentation/flavours/html/templates/alerts/alert_seasonal.html +1 -0
- polars_data_profiling/report/presentation/flavours/html/templates/alerts/alert_skewed.html +1 -0
- polars_data_profiling/report/presentation/flavours/html/templates/alerts/alert_truncated.html +1 -0
- polars_data_profiling/report/presentation/flavours/html/templates/alerts/alert_type_date.html +1 -0
- polars_data_profiling/report/presentation/flavours/html/templates/alerts/alert_uniform.html +1 -0
- polars_data_profiling/report/presentation/flavours/html/templates/alerts/alert_unique.html +1 -0
- polars_data_profiling/report/presentation/flavours/html/templates/alerts/alert_unsupported.html +1 -0
- polars_data_profiling/report/presentation/flavours/html/templates/alerts/alert_zeros.html +1 -0
- polars_data_profiling/report/presentation/flavours/html/templates/alerts.html +47 -0
- polars_data_profiling/report/presentation/flavours/html/templates/collapse.html +31 -0
- polars_data_profiling/report/presentation/flavours/html/templates/correlation_table.html +5 -0
- polars_data_profiling/report/presentation/flavours/html/templates/diagram.html +13 -0
- polars_data_profiling/report/presentation/flavours/html/templates/dropdown.html +25 -0
- polars_data_profiling/report/presentation/flavours/html/templates/duplicate.html +5 -0
- polars_data_profiling/report/presentation/flavours/html/templates/frequency_table.html +45 -0
- polars_data_profiling/report/presentation/flavours/html/templates/frequency_table_small.html +34 -0
- polars_data_profiling/report/presentation/flavours/html/templates/report.html +42 -0
- polars_data_profiling/report/presentation/flavours/html/templates/sample.html +10 -0
- polars_data_profiling/report/presentation/flavours/html/templates/scores.html +78 -0
- polars_data_profiling/report/presentation/flavours/html/templates/sequence/batch_grid.html +16 -0
- polars_data_profiling/report/presentation/flavours/html/templates/sequence/cards.html +41 -0
- polars_data_profiling/report/presentation/flavours/html/templates/sequence/correlations.html +53 -0
- polars_data_profiling/report/presentation/flavours/html/templates/sequence/grid.html +39 -0
- polars_data_profiling/report/presentation/flavours/html/templates/sequence/interactions.html +45 -0
- polars_data_profiling/report/presentation/flavours/html/templates/sequence/list.html +7 -0
- polars_data_profiling/report/presentation/flavours/html/templates/sequence/named_list.html +8 -0
- polars_data_profiling/report/presentation/flavours/html/templates/sequence/overview_tabs.html +47 -0
- polars_data_profiling/report/presentation/flavours/html/templates/sequence/scores.html +3 -0
- polars_data_profiling/report/presentation/flavours/html/templates/sequence/sections.html +15 -0
- polars_data_profiling/report/presentation/flavours/html/templates/sequence/select.html +40 -0
- polars_data_profiling/report/presentation/flavours/html/templates/sequence/tabs.html +30 -0
- polars_data_profiling/report/presentation/flavours/html/templates/table.html +38 -0
- polars_data_profiling/report/presentation/flavours/html/templates/toggle_button.html +18 -0
- polars_data_profiling/report/presentation/flavours/html/templates/variable.html +7 -0
- polars_data_profiling/report/presentation/flavours/html/templates/variable_info.html +49 -0
- polars_data_profiling/report/presentation/flavours/html/templates/wrapper/assets/bootstrap.bundle.min.js +7 -0
- polars_data_profiling/report/presentation/flavours/html/templates/wrapper/assets/bootstrap.min.css +6 -0
- polars_data_profiling/report/presentation/flavours/html/templates/wrapper/assets/cosmo.bootstrap.min.css +12 -0
- polars_data_profiling/report/presentation/flavours/html/templates/wrapper/assets/flatly.bootstrap.min.css +12 -0
- polars_data_profiling/report/presentation/flavours/html/templates/wrapper/assets/script.js +398 -0
- polars_data_profiling/report/presentation/flavours/html/templates/wrapper/assets/simplex.bootstrap.min.css +12 -0
- polars_data_profiling/report/presentation/flavours/html/templates/wrapper/assets/style.css +1455 -0
- polars_data_profiling/report/presentation/flavours/html/templates/wrapper/assets/united.bootstrap.min.css +12 -0
- polars_data_profiling/report/presentation/flavours/html/templates/wrapper/footer.html +6 -0
- polars_data_profiling/report/presentation/flavours/html/templates/wrapper/javascript.html +18 -0
- polars_data_profiling/report/presentation/flavours/html/templates/wrapper/navigation.html +22 -0
- polars_data_profiling/report/presentation/flavours/html/templates/wrapper/style.html +20 -0
- polars_data_profiling/report/presentation/flavours/html/templates.py +79 -0
- polars_data_profiling/report/presentation/flavours/html/theme.py +74 -0
- polars_data_profiling/report/presentation/flavours/html/toggle_button.py +7 -0
- polars_data_profiling/report/presentation/flavours/html/variable.py +7 -0
- polars_data_profiling/report/presentation/flavours/html/variable_info.py +7 -0
- polars_data_profiling/report/presentation/flavours/widget/__init__.py +59 -0
- polars_data_profiling/report/presentation/flavours/widget/alerts.py +43 -0
- polars_data_profiling/report/presentation/flavours/widget/collapse.py +43 -0
- polars_data_profiling/report/presentation/flavours/widget/container.py +127 -0
- polars_data_profiling/report/presentation/flavours/widget/correlation_table.py +16 -0
- polars_data_profiling/report/presentation/flavours/widget/dropdown.py +31 -0
- polars_data_profiling/report/presentation/flavours/widget/duplicate.py +14 -0
- polars_data_profiling/report/presentation/flavours/widget/frequency_table.py +57 -0
- polars_data_profiling/report/presentation/flavours/widget/frequency_table_small.py +64 -0
- polars_data_profiling/report/presentation/flavours/widget/html.py +11 -0
- polars_data_profiling/report/presentation/flavours/widget/image.py +29 -0
- polars_data_profiling/report/presentation/flavours/widget/notebook.py +82 -0
- polars_data_profiling/report/presentation/flavours/widget/root.py +10 -0
- polars_data_profiling/report/presentation/flavours/widget/sample.py +14 -0
- polars_data_profiling/report/presentation/flavours/widget/table.py +30 -0
- polars_data_profiling/report/presentation/flavours/widget/toggle_button.py +17 -0
- polars_data_profiling/report/presentation/flavours/widget/variable.py +12 -0
- polars_data_profiling/report/presentation/flavours/widget/variable_info.py +11 -0
- polars_data_profiling/report/presentation/frequency_table_utils.py +169 -0
- polars_data_profiling/report/structure/__init__.py +1 -0
- polars_data_profiling/report/structure/correlations.py +202 -0
- polars_data_profiling/report/structure/overview.py +506 -0
- polars_data_profiling/report/structure/report.py +547 -0
- polars_data_profiling/report/structure/variables/__init__.py +41 -0
- polars_data_profiling/report/structure/variables/render_boolean.py +130 -0
- polars_data_profiling/report/structure/variables/render_categorical.py +562 -0
- polars_data_profiling/report/structure/variables/render_common.py +34 -0
- polars_data_profiling/report/structure/variables/render_complex.py +102 -0
- polars_data_profiling/report/structure/variables/render_count.py +172 -0
- polars_data_profiling/report/structure/variables/render_date.py +147 -0
- polars_data_profiling/report/structure/variables/render_file.py +68 -0
- polars_data_profiling/report/structure/variables/render_generic.py +45 -0
- polars_data_profiling/report/structure/variables/render_image.py +202 -0
- polars_data_profiling/report/structure/variables/render_path.py +138 -0
- polars_data_profiling/report/structure/variables/render_real.py +314 -0
- polars_data_profiling/report/structure/variables/render_text.py +213 -0
- polars_data_profiling/report/structure/variables/render_timeseries.py +371 -0
- polars_data_profiling/report/structure/variables/render_url.py +132 -0
- polars_data_profiling/report/utils.py +32 -0
- polars_data_profiling/serialize_report.py +144 -0
- polars_data_profiling/utils/__init__.py +1 -0
- polars_data_profiling/utils/collect.py +41 -0
- polars_data_profiling/utils/common.py +29 -0
- polars_data_profiling/utils/dataframe.py +166 -0
- polars_data_profiling/utils/notebook.py +8 -0
- polars_data_profiling/utils/paths.py +46 -0
- polars_data_profiling/utils/progress_bar.py +16 -0
- polars_data_profiling/utils/styles.py +22 -0
- polars_data_profiling/version.py +8 -0
- polars_data_profiling/visualisation/__init__.py +1 -0
- polars_data_profiling/visualisation/charts/__init__.py +16 -0
- polars_data_profiling/visualisation/charts/builders.py +631 -0
- polars_data_profiling/visualisation/charts/palette.py +129 -0
- polars_data_profiling/visualisation/charts/scales.py +204 -0
- polars_data_profiling/visualisation/charts/specs.py +249 -0
- polars_data_profiling/visualisation/charts/svg.py +1336 -0
- polars_data_profiling/visualisation/missing.py +34 -0
- polars_data_profiling/visualisation/plot.py +142 -0
- polars_data_profiling-0.1.0.dist-info/METADATA +131 -0
- polars_data_profiling-0.1.0.dist-info/RECORD +207 -0
- polars_data_profiling-0.1.0.dist-info/WHEEL +4 -0
- polars_data_profiling-0.1.0.dist-info/entry_points.txt +3 -0
- polars_data_profiling-0.1.0.dist-info/licenses/LICENSE +22 -0
- polars_data_profiling-0.1.0.dist-info/licenses/NOTICE +26 -0
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
from polars_data_profiling.config import Settings
|
|
4
|
+
from polars_data_profiling.report.formatters import fmt, fmt_bytesize, fmt_percent
|
|
5
|
+
from polars_data_profiling.report.presentation.core import (
|
|
6
|
+
Container,
|
|
7
|
+
FrequencyTable,
|
|
8
|
+
FrequencyTableSmall,
|
|
9
|
+
Image,
|
|
10
|
+
Table,
|
|
11
|
+
)
|
|
12
|
+
from polars_data_profiling.report.presentation.core.variable_info import VariableInfo
|
|
13
|
+
from polars_data_profiling.report.structure.variables.render_categorical import (
|
|
14
|
+
_get_n,
|
|
15
|
+
freq_table,
|
|
16
|
+
render_categorical,
|
|
17
|
+
render_categorical_frequency,
|
|
18
|
+
render_categorical_length,
|
|
19
|
+
render_categorical_unicode,
|
|
20
|
+
)
|
|
21
|
+
from polars_data_profiling.report.structure.variables.render_common import render_common
|
|
22
|
+
from polars_data_profiling.visualisation.plot import plot_word_cloud
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def _top_words(word_counts: Any, k: int) -> Any:
|
|
26
|
+
"""Most frequent ``k`` words, without an "Other values" remainder."""
|
|
27
|
+
|
|
28
|
+
def top(counts: dict) -> dict:
|
|
29
|
+
return dict(sorted(counts.items(), key=lambda kv: -kv[1])[:k])
|
|
30
|
+
|
|
31
|
+
if isinstance(word_counts, list):
|
|
32
|
+
return [top(wc) for wc in word_counts]
|
|
33
|
+
return top(word_counts)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def render_text(config: Settings, summary: dict[str, Any]) -> dict[str, Any]:
|
|
37
|
+
if config.vars.text.redact:
|
|
38
|
+
render = render_categorical(config, summary)
|
|
39
|
+
return render
|
|
40
|
+
|
|
41
|
+
varid = summary["varid"]
|
|
42
|
+
words = config.vars.text.words
|
|
43
|
+
characters = config.vars.text.characters
|
|
44
|
+
length = config.vars.text.length
|
|
45
|
+
|
|
46
|
+
template_variables = render_common(config, summary)
|
|
47
|
+
|
|
48
|
+
top_items: list[Any] = []
|
|
49
|
+
var_info = VariableInfo(
|
|
50
|
+
anchor_id=varid,
|
|
51
|
+
var_name=summary["varname"],
|
|
52
|
+
var_type=summary["type"],
|
|
53
|
+
alerts=summary["alerts"],
|
|
54
|
+
description=summary["description"],
|
|
55
|
+
style=config.html.style,
|
|
56
|
+
)
|
|
57
|
+
top_items.append(var_info)
|
|
58
|
+
|
|
59
|
+
table = Table(
|
|
60
|
+
[
|
|
61
|
+
{
|
|
62
|
+
"name": "Distinct",
|
|
63
|
+
"value": fmt(summary["n_distinct"]),
|
|
64
|
+
"alert": "n_distinct" in summary["alert_fields"],
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"name": "Distinct (%)",
|
|
68
|
+
"value": fmt_percent(summary["p_distinct"]),
|
|
69
|
+
"alert": "p_distinct" in summary["alert_fields"],
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"name": "Missing",
|
|
73
|
+
"value": fmt(summary["n_missing"]),
|
|
74
|
+
"alert": "n_missing" in summary["alert_fields"],
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"name": "Missing (%)",
|
|
78
|
+
"value": fmt_percent(summary["p_missing"]),
|
|
79
|
+
"alert": "p_missing" in summary["alert_fields"],
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"name": "Memory size",
|
|
83
|
+
"value": fmt_bytesize(summary["memory_size"]),
|
|
84
|
+
"alert": False,
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
style=config.html.style,
|
|
88
|
+
)
|
|
89
|
+
top_items.append(table)
|
|
90
|
+
|
|
91
|
+
if words and "word_counts" in summary:
|
|
92
|
+
mini_wordcloud = Image(
|
|
93
|
+
plot_word_cloud(config, summary["word_counts"]),
|
|
94
|
+
image_format=config.plot.image_format,
|
|
95
|
+
alt="Mini wordcloud",
|
|
96
|
+
)
|
|
97
|
+
top_items.append(mini_wordcloud)
|
|
98
|
+
top_words = _top_words(summary["word_counts"], 5)
|
|
99
|
+
top_items.append(
|
|
100
|
+
FrequencyTableSmall(
|
|
101
|
+
freq_table(
|
|
102
|
+
freqtable=top_words,
|
|
103
|
+
n=_get_n(top_words),
|
|
104
|
+
max_number_to_print=5,
|
|
105
|
+
),
|
|
106
|
+
redact=config.vars.text.redact,
|
|
107
|
+
name="Top 5 words",
|
|
108
|
+
)
|
|
109
|
+
)
|
|
110
|
+
template_variables["top"] = Container(top_items, sequence_type="grid")
|
|
111
|
+
|
|
112
|
+
# ============================================================================================
|
|
113
|
+
|
|
114
|
+
bottom_items = []
|
|
115
|
+
overview_items = []
|
|
116
|
+
# length isn't being computed for categorical in spark
|
|
117
|
+
if length and "max_length" in summary:
|
|
118
|
+
length_table, length_histo = render_categorical_length(config, summary, varid)
|
|
119
|
+
overview_items.append(length_table)
|
|
120
|
+
|
|
121
|
+
# characters isn't being computed for categorical in spark
|
|
122
|
+
unitab = None
|
|
123
|
+
if characters and "category_alias_counts" in summary:
|
|
124
|
+
overview_table_char, unitab = render_categorical_unicode(config, summary, varid)
|
|
125
|
+
overview_items.append(overview_table_char)
|
|
126
|
+
|
|
127
|
+
unique_stats = render_categorical_frequency(config, summary, varid)
|
|
128
|
+
overview_items.append(unique_stats)
|
|
129
|
+
|
|
130
|
+
if not config.vars.text.redact:
|
|
131
|
+
rows = ("1st row", "2nd row", "3rd row", "4th row", "5th row")
|
|
132
|
+
|
|
133
|
+
if isinstance(summary["first_rows"], list):
|
|
134
|
+
sample = Table(
|
|
135
|
+
[
|
|
136
|
+
{
|
|
137
|
+
"name": name,
|
|
138
|
+
"value": fmt(value),
|
|
139
|
+
"alert": False,
|
|
140
|
+
}
|
|
141
|
+
for name, *value in zip(rows, *summary["first_rows"])
|
|
142
|
+
],
|
|
143
|
+
name="Sample",
|
|
144
|
+
style=config.html.style,
|
|
145
|
+
)
|
|
146
|
+
else:
|
|
147
|
+
sample = Table(
|
|
148
|
+
[
|
|
149
|
+
{
|
|
150
|
+
"name": name,
|
|
151
|
+
"value": fmt(value),
|
|
152
|
+
"alert": False,
|
|
153
|
+
}
|
|
154
|
+
for name, value in zip(rows, summary["first_rows"])
|
|
155
|
+
],
|
|
156
|
+
name="Sample",
|
|
157
|
+
style=config.html.style,
|
|
158
|
+
)
|
|
159
|
+
overview_items.append(sample)
|
|
160
|
+
overview = Container(
|
|
161
|
+
overview_items,
|
|
162
|
+
name="Overview",
|
|
163
|
+
anchor_id=f"{varid}overview",
|
|
164
|
+
sequence_type="batch_grid",
|
|
165
|
+
batch_size=len(overview_items),
|
|
166
|
+
titles=False,
|
|
167
|
+
)
|
|
168
|
+
bottom_items.append(overview)
|
|
169
|
+
|
|
170
|
+
if words and "word_counts" in summary:
|
|
171
|
+
woc = freq_table(
|
|
172
|
+
freqtable=summary["word_counts"],
|
|
173
|
+
n=_get_n(summary["word_counts"]),
|
|
174
|
+
max_number_to_print=10,
|
|
175
|
+
)
|
|
176
|
+
|
|
177
|
+
fqwo = FrequencyTable(
|
|
178
|
+
woc,
|
|
179
|
+
name="Common words",
|
|
180
|
+
anchor_id=f"{varid}cwo",
|
|
181
|
+
redact=config.vars.text.redact,
|
|
182
|
+
)
|
|
183
|
+
|
|
184
|
+
image = Image(
|
|
185
|
+
plot_word_cloud(config, summary["word_counts"]),
|
|
186
|
+
image_format=config.plot.image_format,
|
|
187
|
+
alt="Wordcloud",
|
|
188
|
+
)
|
|
189
|
+
|
|
190
|
+
bottom_items.append(
|
|
191
|
+
Container(
|
|
192
|
+
[fqwo, image],
|
|
193
|
+
name="Words",
|
|
194
|
+
anchor_id=f"{varid}word",
|
|
195
|
+
sequence_type="grid",
|
|
196
|
+
)
|
|
197
|
+
)
|
|
198
|
+
|
|
199
|
+
if unitab is not None:
|
|
200
|
+
bottom_items.append(
|
|
201
|
+
Container(
|
|
202
|
+
[unitab],
|
|
203
|
+
name="Characters",
|
|
204
|
+
anchor_id=f"{varid}characters",
|
|
205
|
+
sequence_type="grid",
|
|
206
|
+
)
|
|
207
|
+
)
|
|
208
|
+
|
|
209
|
+
template_variables["bottom"] = Container(
|
|
210
|
+
bottom_items, sequence_type="tabs", anchor_id=f"{varid}bottom"
|
|
211
|
+
)
|
|
212
|
+
|
|
213
|
+
return template_variables
|
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
from polars_data_profiling.config import Settings
|
|
2
|
+
from polars_data_profiling.report.formatters import (
|
|
3
|
+
fmt,
|
|
4
|
+
fmt_bytesize,
|
|
5
|
+
fmt_monotonic,
|
|
6
|
+
fmt_numeric,
|
|
7
|
+
fmt_percent,
|
|
8
|
+
fmt_timespan_timedelta,
|
|
9
|
+
)
|
|
10
|
+
from polars_data_profiling.report.presentation.core import (
|
|
11
|
+
Container,
|
|
12
|
+
FrequencyTable,
|
|
13
|
+
Image,
|
|
14
|
+
Table,
|
|
15
|
+
VariableInfo,
|
|
16
|
+
)
|
|
17
|
+
from polars_data_profiling.report.structure.variables.render_common import render_common
|
|
18
|
+
from polars_data_profiling.report.utils import image_or_empty
|
|
19
|
+
from polars_data_profiling.visualisation.plot import (
|
|
20
|
+
histogram,
|
|
21
|
+
mini_ts_plot,
|
|
22
|
+
plot_acf_pacf,
|
|
23
|
+
plot_timeseries_gap_analysis,
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def _render_gap_tab(config: Settings, summary: dict) -> Container:
|
|
28
|
+
gap_stats = [
|
|
29
|
+
{
|
|
30
|
+
"name": "number of gaps",
|
|
31
|
+
"value": fmt_numeric(
|
|
32
|
+
summary["gap_stats"]["n_gaps"], precision=config.report.precision
|
|
33
|
+
),
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"name": "min",
|
|
37
|
+
"value": fmt_timespan_timedelta(
|
|
38
|
+
summary["gap_stats"]["min"], precision=config.report.precision
|
|
39
|
+
),
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"name": "max",
|
|
43
|
+
"value": fmt_timespan_timedelta(
|
|
44
|
+
summary["gap_stats"]["max"], precision=config.report.precision
|
|
45
|
+
),
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"name": "mean",
|
|
49
|
+
"value": fmt_timespan_timedelta(
|
|
50
|
+
summary["gap_stats"]["mean"], precision=config.report.precision
|
|
51
|
+
),
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"name": "std",
|
|
55
|
+
"value": fmt_timespan_timedelta(
|
|
56
|
+
summary["gap_stats"]["std"], precision=config.report.precision
|
|
57
|
+
),
|
|
58
|
+
},
|
|
59
|
+
]
|
|
60
|
+
|
|
61
|
+
gap_table = Table(
|
|
62
|
+
gap_stats,
|
|
63
|
+
name="Gap statistics",
|
|
64
|
+
style=config.html.style,
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
gap_plot = Image(
|
|
68
|
+
plot_timeseries_gap_analysis(
|
|
69
|
+
config, summary["gap_stats"]["series"], summary["gap_stats"]["gaps"]
|
|
70
|
+
),
|
|
71
|
+
image_format=config.plot.image_format,
|
|
72
|
+
alt="Gap plot",
|
|
73
|
+
name="",
|
|
74
|
+
anchor_id=f"{summary['varid']}_gap_plot",
|
|
75
|
+
)
|
|
76
|
+
return Container(
|
|
77
|
+
[gap_table, gap_plot],
|
|
78
|
+
image_format=config.plot.image_format,
|
|
79
|
+
sequence_type="grid",
|
|
80
|
+
name="Gap analysis",
|
|
81
|
+
anchor_id=f"{summary['varid']}_gap_analysis",
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def render_timeseries(config: Settings, summary: dict) -> dict:
|
|
86
|
+
varid = summary["varid"]
|
|
87
|
+
template_variables = render_common(config, summary)
|
|
88
|
+
image_format = config.plot.image_format
|
|
89
|
+
name = "Numeric time series"
|
|
90
|
+
|
|
91
|
+
# Top
|
|
92
|
+
info = VariableInfo(
|
|
93
|
+
summary["varid"],
|
|
94
|
+
summary["varname"],
|
|
95
|
+
name,
|
|
96
|
+
summary["alerts"],
|
|
97
|
+
summary["description"],
|
|
98
|
+
style=config.html.style,
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
table1 = Table(
|
|
102
|
+
[
|
|
103
|
+
{
|
|
104
|
+
"name": "Distinct",
|
|
105
|
+
"value": fmt(summary["n_distinct"]),
|
|
106
|
+
"alert": "n_distinct" in summary["alert_fields"],
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"name": "Distinct (%)",
|
|
110
|
+
"value": fmt_percent(summary["p_distinct"]),
|
|
111
|
+
"alert": "p_distinct" in summary["alert_fields"],
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"name": "Missing",
|
|
115
|
+
"value": fmt(summary["n_missing"]),
|
|
116
|
+
"alert": "n_missing" in summary["alert_fields"],
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"name": "Missing (%)",
|
|
120
|
+
"value": fmt_percent(summary["p_missing"]),
|
|
121
|
+
"alert": "p_missing" in summary["alert_fields"],
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"name": "Infinite",
|
|
125
|
+
"value": fmt(summary["n_infinite"]),
|
|
126
|
+
"alert": "n_infinite" in summary["alert_fields"],
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
"name": "Infinite (%)",
|
|
130
|
+
"value": fmt_percent(summary["p_infinite"]),
|
|
131
|
+
"alert": "p_infinite" in summary["alert_fields"],
|
|
132
|
+
},
|
|
133
|
+
],
|
|
134
|
+
style=config.html.style,
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
table2 = Table(
|
|
138
|
+
[
|
|
139
|
+
{
|
|
140
|
+
"name": "Mean",
|
|
141
|
+
"value": fmt_numeric(
|
|
142
|
+
summary["mean"], precision=config.report.precision
|
|
143
|
+
),
|
|
144
|
+
"alert": False,
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
"name": "Minimum",
|
|
148
|
+
"value": fmt_numeric(summary["min"], precision=config.report.precision),
|
|
149
|
+
"alert": False,
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
"name": "Maximum",
|
|
153
|
+
"value": fmt_numeric(summary["max"], precision=config.report.precision),
|
|
154
|
+
"alert": False,
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
"name": "Zeros",
|
|
158
|
+
"value": fmt(summary["n_zeros"]),
|
|
159
|
+
"alert": "n_zeros" in summary["alert_fields"],
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
"name": "Zeros (%)",
|
|
163
|
+
"value": fmt_percent(summary["p_zeros"]),
|
|
164
|
+
"alert": "p_zeros" in summary["alert_fields"],
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
"name": "Memory size",
|
|
168
|
+
"value": fmt_bytesize(summary["memory_size"]),
|
|
169
|
+
"alert": False,
|
|
170
|
+
},
|
|
171
|
+
],
|
|
172
|
+
style=config.html.style,
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
mini_plot = Image(
|
|
176
|
+
mini_ts_plot(config, summary["series"]),
|
|
177
|
+
image_format=image_format,
|
|
178
|
+
alt="Mini TS plot",
|
|
179
|
+
)
|
|
180
|
+
|
|
181
|
+
template_variables["top"] = Container(
|
|
182
|
+
[info, table1, table2, mini_plot], sequence_type="grid"
|
|
183
|
+
)
|
|
184
|
+
|
|
185
|
+
quantile_statistics = Table(
|
|
186
|
+
[
|
|
187
|
+
{
|
|
188
|
+
"name": "Minimum",
|
|
189
|
+
"value": fmt_numeric(summary["min"], precision=config.report.precision),
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
"name": "5-th percentile",
|
|
193
|
+
"value": fmt_numeric(summary["5%"], precision=config.report.precision),
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
"name": "Q1",
|
|
197
|
+
"value": fmt_numeric(summary["25%"], precision=config.report.precision),
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
"name": "median",
|
|
201
|
+
"value": fmt_numeric(summary["50%"], precision=config.report.precision),
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
"name": "Q3",
|
|
205
|
+
"value": fmt_numeric(summary["75%"], precision=config.report.precision),
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
"name": "95-th percentile",
|
|
209
|
+
"value": fmt_numeric(summary["95%"], precision=config.report.precision),
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
"name": "Maximum",
|
|
213
|
+
"value": fmt_numeric(summary["max"], precision=config.report.precision),
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
"name": "Range",
|
|
217
|
+
"value": fmt_numeric(
|
|
218
|
+
summary["range"], precision=config.report.precision
|
|
219
|
+
),
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
"name": "Interquartile range (IQR)",
|
|
223
|
+
"value": fmt_numeric(summary["iqr"], precision=config.report.precision),
|
|
224
|
+
},
|
|
225
|
+
],
|
|
226
|
+
name="Quantile statistics",
|
|
227
|
+
style=config.html.style,
|
|
228
|
+
)
|
|
229
|
+
|
|
230
|
+
descriptive_statistics = Table(
|
|
231
|
+
[
|
|
232
|
+
{
|
|
233
|
+
"name": "Standard deviation",
|
|
234
|
+
"value": fmt_numeric(summary["std"], precision=config.report.precision),
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
"name": "Coefficient of variation (CV)",
|
|
238
|
+
"value": fmt_numeric(summary["cv"], precision=config.report.precision),
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
"name": "Kurtosis",
|
|
242
|
+
"value": fmt_numeric(
|
|
243
|
+
summary["kurtosis"], precision=config.report.precision
|
|
244
|
+
),
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
"name": "Mean",
|
|
248
|
+
"value": fmt_numeric(
|
|
249
|
+
summary["mean"], precision=config.report.precision
|
|
250
|
+
),
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
"name": "Median Absolute Deviation (MAD)",
|
|
254
|
+
"value": fmt_numeric(summary["mad"], precision=config.report.precision),
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
"name": "Skewness",
|
|
258
|
+
"value": fmt_numeric(
|
|
259
|
+
summary["skewness"], precision=config.report.precision
|
|
260
|
+
),
|
|
261
|
+
"class": "alert" if "skewness" in summary["alert_fields"] else "",
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
"name": "Sum",
|
|
265
|
+
"value": fmt_numeric(summary["sum"], precision=config.report.precision),
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
"name": "Variance",
|
|
269
|
+
"value": fmt_numeric(
|
|
270
|
+
summary["variance"], precision=config.report.precision
|
|
271
|
+
),
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
"name": "Monotonicity",
|
|
275
|
+
"value": fmt_monotonic(summary["monotonic"]),
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
"name": "Augmented Dickey-Fuller test p-value",
|
|
279
|
+
"value": fmt_numeric(summary["addfuller"]),
|
|
280
|
+
},
|
|
281
|
+
],
|
|
282
|
+
name="Descriptive statistics",
|
|
283
|
+
style=config.html.style,
|
|
284
|
+
)
|
|
285
|
+
|
|
286
|
+
statistics = Container(
|
|
287
|
+
[quantile_statistics, descriptive_statistics],
|
|
288
|
+
anchor_id=f"{varid}statistics",
|
|
289
|
+
name="Statistics",
|
|
290
|
+
sequence_type="grid",
|
|
291
|
+
)
|
|
292
|
+
|
|
293
|
+
summary_histogram = summary.get("histogram", [])
|
|
294
|
+
|
|
295
|
+
hist_data = None
|
|
296
|
+
hist_caption = None
|
|
297
|
+
|
|
298
|
+
if summary_histogram:
|
|
299
|
+
if isinstance(summary_histogram, list):
|
|
300
|
+
hist_data = histogram(
|
|
301
|
+
config,
|
|
302
|
+
[x[0] for x in summary["histogram"]],
|
|
303
|
+
[x[1] for x in summary["histogram"]],
|
|
304
|
+
)
|
|
305
|
+
hist_caption = f"<strong>Histogram with fixed size bins</strong> (bins={len(summary['histogram'][0][1]) - 1})"
|
|
306
|
+
else:
|
|
307
|
+
hist_data = histogram(config, *summary["histogram"])
|
|
308
|
+
hist_caption = f"<strong>Histogram with fixed size bins</strong> (bins={len(summary['histogram'][1]) - 1})"
|
|
309
|
+
|
|
310
|
+
hist = image_or_empty(
|
|
311
|
+
hist_data,
|
|
312
|
+
image_format=image_format,
|
|
313
|
+
alt="Histogram",
|
|
314
|
+
caption=hist_caption,
|
|
315
|
+
name="Histogram",
|
|
316
|
+
anchor_id=f"{varid}histogram",
|
|
317
|
+
)
|
|
318
|
+
|
|
319
|
+
fq = FrequencyTable(
|
|
320
|
+
template_variables["freq_table_rows"],
|
|
321
|
+
name="Common values",
|
|
322
|
+
anchor_id=f"{varid}common_values",
|
|
323
|
+
redact=False,
|
|
324
|
+
)
|
|
325
|
+
|
|
326
|
+
evs = Container(
|
|
327
|
+
[
|
|
328
|
+
FrequencyTable(
|
|
329
|
+
template_variables["firstn_expanded"],
|
|
330
|
+
name=f"Minimum {config.n_extreme_obs} values",
|
|
331
|
+
anchor_id=f"{varid}firstn",
|
|
332
|
+
redact=False,
|
|
333
|
+
),
|
|
334
|
+
FrequencyTable(
|
|
335
|
+
template_variables["lastn_expanded"],
|
|
336
|
+
name=f"Maximum {config.n_extreme_obs} values",
|
|
337
|
+
anchor_id=f"{varid}lastn",
|
|
338
|
+
redact=False,
|
|
339
|
+
),
|
|
340
|
+
],
|
|
341
|
+
sequence_type="tabs",
|
|
342
|
+
name="Extreme values",
|
|
343
|
+
anchor_id=f"{varid}extreme_values",
|
|
344
|
+
)
|
|
345
|
+
|
|
346
|
+
acf_pacf = Image(
|
|
347
|
+
plot_acf_pacf(config, summary["series"]),
|
|
348
|
+
image_format=image_format,
|
|
349
|
+
alt="Autocorrelation",
|
|
350
|
+
caption="<strong>ACF and PACF</strong>",
|
|
351
|
+
name="Autocorrelation",
|
|
352
|
+
anchor_id=f"{varid}acf_pacf",
|
|
353
|
+
)
|
|
354
|
+
|
|
355
|
+
ts_plot = Image(
|
|
356
|
+
mini_ts_plot(config, summary["series"], figsize=(7, 3)),
|
|
357
|
+
image_format=image_format,
|
|
358
|
+
alt="Time-series plot",
|
|
359
|
+
name="Time-series",
|
|
360
|
+
anchor_id=f"{varid}_ts_plot",
|
|
361
|
+
)
|
|
362
|
+
|
|
363
|
+
ts_gap = _render_gap_tab(config, summary)
|
|
364
|
+
|
|
365
|
+
template_variables["bottom"] = Container(
|
|
366
|
+
[statistics, hist, ts_plot, ts_gap, fq, evs, acf_pacf],
|
|
367
|
+
sequence_type="tabs",
|
|
368
|
+
anchor_id=f"{varid}bottom",
|
|
369
|
+
)
|
|
370
|
+
|
|
371
|
+
return template_variables
|