From ca43fc80f037aea2ac37d705a9c568dd0dbb2b1f Mon Sep 17 00:00:00 2001 From: Alex Barros Date: Wed, 7 Aug 2024 11:01:31 -0300 Subject: [PATCH 1/2] fix: suppress pandas tick resolution adjustment (#1635) * fix: suppress pandas tick resolution adjustment * fix: remove unused import * fix: file typo * fix: ts plot x axis date format * chore: upgrade wordcloud version * fix: re-enable compatibility mode * fix: ensure type_schema for testing --- requirements.txt | 2 +- src/ydata_profiling/visualisation/plot.py | 7 ++--- tests/issues/test_issue1631.py | 27 +++++++++++++++++++ .../{test_issus915.py => test_issue915.py} | 0 4 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 tests/issues/test_issue1631.py rename tests/issues/{test_issus915.py => test_issue915.py} (100%) diff --git a/requirements.txt b/requirements.txt index bd56376c3..a98d0f03e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -22,6 +22,6 @@ statsmodels>=0.13.2, <1 # type checking typeguard>=3, <5 imagehash==4.3.1 -wordcloud>=1.9.1 +wordcloud>=1.9.3 dacite>=1.8 numba>=0.56.0, <1 \ No newline at end of file diff --git a/src/ydata_profiling/visualisation/plot.py b/src/ydata_profiling/visualisation/plot.py index be2286c58..a2df1fd5d 100644 --- a/src/ydata_profiling/visualisation/plot.py +++ b/src/ydata_profiling/visualisation/plot.py @@ -592,13 +592,14 @@ def plot_timeseries_gap_analysis( label=label, color=color, alpha=0.65, + x_compat=True, ) _format_ts_date_axis(serie, ax) ax.yaxis.set_major_locator(MaxNLocator(integer=True)) for gap in gaps_: ax.fill_between(x=gap, y1=min_, y2=max_, color=color, alpha=0.25) else: - series.plot(ax=ax) + series.plot(ax=ax, x_compat=True) _format_ts_date_axis(series, ax) ax.yaxis.set_major_locator(MaxNLocator(integer=True)) @@ -677,11 +678,11 @@ def _plot_timeseries( colors = create_comparison_color_list(config) for serie, color, label in zip(series, colors, labels): - ax = serie.plot(color=color, label=label, alpha=0.75) + ax = serie.plot(color=color, label=label, alpha=0.75, x_compat=True) _format_ts_date_axis(serie, ax) else: - ax = series.plot(color=config.html.style.primary_colors[0]) + ax = series.plot(color=config.html.style.primary_colors[0], x_compat=True) _format_ts_date_axis(series, ax) return plot diff --git a/tests/issues/test_issue1631.py b/tests/issues/test_issue1631.py new file mode 100644 index 000000000..88ed22002 --- /dev/null +++ b/tests/issues/test_issue1631.py @@ -0,0 +1,27 @@ +""" +Test for issue 1631: +https://github.com/ydataai/ydata-profiling/issues/1631 +""" +import pandas as pd + +from ydata_profiling import ProfileReport + + +def test_issue1631(test_output_dir): + data = { + "value": [1, 2, 3, 4], + "datetime": [ + "2022-10-01 00:10:00", + "2022-10-02 00:20:00", + "2022-10-03 00:30:00", + "2022-10-04 00:40:00", + ], + } + df = pd.DataFrame(data) + df["datetime"] = pd.to_datetime(df["datetime"], errors="raise") + df.set_index("datetime", inplace=True) + profile = ProfileReport(df, tsmode=True, type_schema={"value": "timeseries"}) + output_file = test_output_dir / "issue1631.html" + profile.to_file(output_file) + + assert output_file.exists() diff --git a/tests/issues/test_issus915.py b/tests/issues/test_issue915.py similarity index 100% rename from tests/issues/test_issus915.py rename to tests/issues/test_issue915.py From c2b81e5d6bd1dd048db74fbedd023504019974da Mon Sep 17 00:00:00 2001 From: alexbarros Date: Thu, 8 Aug 2024 11:02:10 -0300 Subject: [PATCH 2/2] fix: remove compare report type enforcement --- src/ydata_profiling/compare_reports.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/ydata_profiling/compare_reports.py b/src/ydata_profiling/compare_reports.py index a208f3588..c6108f888 100644 --- a/src/ydata_profiling/compare_reports.py +++ b/src/ydata_profiling/compare_reports.py @@ -138,10 +138,6 @@ def _compare_profile_report_preprocess( config.html.style.primary_colors ) - # enforce same types - for report in reports[1:]: - report._typeset = reports[0].typeset - # Obtain description sets descriptions = [report.get_description() for report in reports] for label, description in zip(labels, descriptions):