Skip to content

Fix: Handle DateIndex in CSA plot_data to resolve crash (fixes #1864)#2302

Open
shivamlalakiya wants to merge 1 commit intopymc-labs:mainfrom
shivamlalakiya:fix/date-index-plotting
Open

Fix: Handle DateIndex in CSA plot_data to resolve crash (fixes #1864)#2302
shivamlalakiya wants to merge 1 commit intopymc-labs:mainfrom
shivamlalakiya:fix/date-index-plotting

Conversation

@shivamlalakiya
Copy link
Contributor

@shivamlalakiya shivamlalakiya commented Feb 18, 2026

Description

I updated the plotting logic in mv_its.py to use direct matplotlib calls instead of pandas.plot(). This fixes a crash that occurs when the input data has a DatetimeIndex, as reported in issue #1864.

Changes included:

  • Replaced data.plot(ax=ax) with ax.plot(data.index, data.values).
  • Added a regression test in tests/customer_choice/test_mv_its.py to verify that plotting with a DateIndex no longer errors.

Related Issue

Checklist


📚 Documentation preview 📚: https://pymc-marketing--2302.org.readthedocs.build/en/2302/

@cursor
Copy link

cursor bot commented Feb 18, 2026

PR Summary

Low Risk
Small plotting-only change with a focused regression test; minimal impact outside visualization behavior (legend/line rendering).

Overview
Fixes a crash in MVITS.plot_data/plot_product when the input has a DatetimeIndex by replacing pandas.DataFrame.plot() usage with explicit matplotlib ax.plot(...) calls per column, and always adding a legend.

Adds a regression test (test_plot_data_with_datetime_index) to ensure plotting works for time series indexed by dates.

Written by Cursor Bugbot for commit 81e7f4f. This will update automatically on new commits. Configure here.

@github-actions github-actions bot added tests customer choice Related to customer choice module bug Something isn't working good first issue Good for newcomers . Doesn't require extensive knowledge of the repo and package plots labels Feb 18, 2026
@codecov
Copy link

codecov bot commented Feb 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.05%. Comparing base (43f39c7) to head (81e7f4f).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2302   +/-   ##
=======================================
  Coverage   93.05%   93.05%           
=======================================
  Files          78       78           
  Lines       12228    12230    +2     
=======================================
+ Hits        11379    11381    +2     
  Misses        849      849           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working customer choice Related to customer choice module good first issue Good for newcomers . Doesn't require extensive knowledge of the repo and package plots tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

data with date index doesn't plot correctly

1 participant