Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: dataset comparison default names #1159

Merged
merged 1 commit into from
Nov 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/pandas_profiling/compare_reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ def _placeholders(*reports: dict) -> None:
report["table"]["types"][type_key] = 0


def _update_titles(reports: List[ProfileReport]) -> None:
"""Redefine title of reports with the default one."""
for idx, report in enumerate(reports):
if report.config.title == "Pandas Profiling Report":
report.config.title = f"Dataset {chr(65 + idx)}"


def _compare_title(titles: List[str]) -> str:
if all(titles[0] == title for title in titles[1:]):
return titles[0]
Expand All @@ -120,6 +127,9 @@ def _compare_profile_report_preprocess(

# Obtain description sets
descriptions = [report.get_description() for report in reports]
for label, description in zip(labels, descriptions):
description["analysis"]["title"] = label

return labels, descriptions


Expand Down Expand Up @@ -184,6 +194,7 @@ def compare(
if all(isinstance(report, ProfileReport) for report in reports):
# Type ignore is needed as mypy does not pick up on the type narrowing
# Consider using TypeGuard (3.10): https://docs.python.org/3/library/typing.html#typing.TypeGuard
_update_titles(reports)
labels, descriptions = _compare_profile_report_preprocess(reports) # type: ignore
elif all(isinstance(report, dict) for report in reports):
labels, descriptions = _compare_dataset_description_preprocess(reports) # type: ignore
Expand Down