Skip to content

Commit

Permalink
Merge pull request #331 from pandas-profiling/reject-const
Browse files Browse the repository at this point in the history
Reject const
  • Loading branch information
sbrugman authored Jan 14, 2020
2 parents 889bf22 + 8a4a540 commit 16e4a16
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
20 changes: 19 additions & 1 deletion src/pandas_profiling/model/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ class MessageType(Enum):
"""This variable is likely a datetime, but treated as categorical."""

UNIQUE = 12
"""This variable has unique values."""

CONSTANT_LENGTH = 13
"""This variable has a constant length"""

REJECTED = 15
"""Variables are rejected if we do not want to consider them for further analysis."""
Expand Down Expand Up @@ -164,7 +168,7 @@ def check_variable_messages(col: str, description: dict) -> List[Message]:
)

# Categorical
if description["type"] in {Variable.TYPE_CAT}:
if description["type"] == Variable.TYPE_CAT:
if description["date_warning"]:
messages.append(
Message(column_name=col, message_type=MessageType.TYPE_DATE, values={})
Expand All @@ -183,6 +187,20 @@ def check_variable_messages(col: str, description: dict) -> List[Message]:
)
)

# Constant length
if (
"composition" in description
and description["min_length"] == description["max_length"]
):
messages.append(
Message(
column_name=col,
message_type=MessageType.CONSTANT_LENGTH,
values=description,
fields={"composition_min_length", "composition_max_length"},
)
)

# Numerical
if description["type"] in {Variable.TYPE_NUM}:
# Skewness
Expand Down
6 changes: 5 additions & 1 deletion src/pandas_profiling/report/structure/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
ImagePath,
Generic,
)
from pandas_profiling.model.messages import MessageType
from pandas_profiling.report.structure.variables import (
render_boolean,
render_categorical,
Expand Down Expand Up @@ -144,13 +145,16 @@ def fmt_warning(warning):
# Per type template variables
template_variables.update(type_to_func[summary["type"]](template_variables))

# Ignore these
ignore = summary["type"] == Generic or MessageType.CONST.value in warnings

templs.append(
Preview(
template_variables["top"],
template_variables["bottom"],
anchor_id=template_variables["varid"],
name=idx,
ignore="ignore" in template_variables,
ignore=ignore,
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def render_generic(summary):
return {
"top": Sequence([info, table, HTML("")], sequence_type="grid"),
"bottom": None,
"ignore": "ignore",
}

# Add class Ignore
Expand Down

0 comments on commit 16e4a16

Please sign in to comment.