From 1cf71c68709b0df6b98a63ac3a9ed053b9ef2e52 Mon Sep 17 00:00:00 2001 From: Alex Barros Date: Mon, 7 Aug 2023 09:57:49 -0300 Subject: [PATCH] fix: handle text as categoricals if sensitive=True (#1415) --- .../report/structure/variables/render_categorical.py | 6 +++++- .../report/structure/variables/render_text.py | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/ydata_profiling/report/structure/variables/render_categorical.py b/src/ydata_profiling/report/structure/variables/render_categorical.py index 0ef2aa04a..86f5a262a 100644 --- a/src/ydata_profiling/report/structure/variables/render_categorical.py +++ b/src/ydata_profiling/report/structure/variables/render_categorical.py @@ -339,10 +339,14 @@ def render_categorical(config: Settings, summary: dict) -> dict: template_variables = render_common(config, summary) + type_name = summary["type"] + if isinstance(type_name, list): + type_name = type_name[0] + info = VariableInfo( summary["varid"], summary["varname"], - "Categorical", + type_name, summary["alerts"], summary["description"], style=config.html.style, diff --git a/src/ydata_profiling/report/structure/variables/render_text.py b/src/ydata_profiling/report/structure/variables/render_text.py index 227ffa9f6..5eadf3799 100644 --- a/src/ydata_profiling/report/structure/variables/render_text.py +++ b/src/ydata_profiling/report/structure/variables/render_text.py @@ -12,6 +12,7 @@ from ydata_profiling.report.structure.variables.render_categorical import ( _get_n, freq_table, + render_categorical, render_categorical_frequency, render_categorical_length, render_categorical_unicode, @@ -21,6 +22,10 @@ def render_text(config: Settings, summary: Dict[str, Any]) -> Dict[str, Any]: + if config.vars.text.redact: + render = render_categorical(config, summary) + return render + varid = summary["varid"] words = config.vars.text.words characters = config.vars.text.characters