Skip to content

Commit ca43fc8

Browse files
authored
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
1 parent 5a185b0 commit ca43fc8

4 files changed

Lines changed: 32 additions & 4 deletions

File tree

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ statsmodels>=0.13.2, <1
2222
# type checking
2323
typeguard>=3, <5
2424
imagehash==4.3.1
25-
wordcloud>=1.9.1
25+
wordcloud>=1.9.3
2626
dacite>=1.8
2727
numba>=0.56.0, <1

src/ydata_profiling/visualisation/plot.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -592,13 +592,14 @@ def plot_timeseries_gap_analysis(
592592
label=label,
593593
color=color,
594594
alpha=0.65,
595+
x_compat=True,
595596
)
596597
_format_ts_date_axis(serie, ax)
597598
ax.yaxis.set_major_locator(MaxNLocator(integer=True))
598599
for gap in gaps_:
599600
ax.fill_between(x=gap, y1=min_, y2=max_, color=color, alpha=0.25)
600601
else:
601-
series.plot(ax=ax)
602+
series.plot(ax=ax, x_compat=True)
602603
_format_ts_date_axis(series, ax)
603604
ax.yaxis.set_major_locator(MaxNLocator(integer=True))
604605

@@ -677,11 +678,11 @@ def _plot_timeseries(
677678
colors = create_comparison_color_list(config)
678679

679680
for serie, color, label in zip(series, colors, labels):
680-
ax = serie.plot(color=color, label=label, alpha=0.75)
681+
ax = serie.plot(color=color, label=label, alpha=0.75, x_compat=True)
681682
_format_ts_date_axis(serie, ax)
682683

683684
else:
684-
ax = series.plot(color=config.html.style.primary_colors[0])
685+
ax = series.plot(color=config.html.style.primary_colors[0], x_compat=True)
685686
_format_ts_date_axis(series, ax)
686687

687688
return plot

tests/issues/test_issue1631.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
"""
2+
Test for issue 1631:
3+
https://github.com/ydataai/ydata-profiling/issues/1631
4+
"""
5+
import pandas as pd
6+
7+
from ydata_profiling import ProfileReport
8+
9+
10+
def test_issue1631(test_output_dir):
11+
data = {
12+
"value": [1, 2, 3, 4],
13+
"datetime": [
14+
"2022-10-01 00:10:00",
15+
"2022-10-02 00:20:00",
16+
"2022-10-03 00:30:00",
17+
"2022-10-04 00:40:00",
18+
],
19+
}
20+
df = pd.DataFrame(data)
21+
df["datetime"] = pd.to_datetime(df["datetime"], errors="raise")
22+
df.set_index("datetime", inplace=True)
23+
profile = ProfileReport(df, tsmode=True, type_schema={"value": "timeseries"})
24+
output_file = test_output_dir / "issue1631.html"
25+
profile.to_file(output_file)
26+
27+
assert output_file.exists()

0 commit comments

Comments
 (0)