Skip to content

Commit

Permalink
fix: suppress pandas tick resolution adjustment (#1635)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
alexbarros authored Aug 7, 2024
1 parent 5a185b0 commit ca43fc8
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 4 additions & 3 deletions src/ydata_profiling/visualisation/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down Expand Up @@ -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
Expand Down
27 changes: 27 additions & 0 deletions tests/issues/test_issue1631.py
Original file line number Diff line number Diff line change
@@ -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()
File renamed without changes.

0 comments on commit ca43fc8

Please sign in to comment.