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

TypeError using plot_forecasts #179

Closed
miroslaavi opened this issue Mar 2, 2024 · 0 comments · Fixed by #181
Closed

TypeError using plot_forecasts #179

miroslaavi opened this issue Mar 2, 2024 · 0 comments · Fixed by #181
Assignees
Labels
bug Something isn't working plotting Plotting features

Comments

@miroslaavi
Copy link
Contributor

miroslaavi commented Mar 2, 2024

When trying to plot using functime plot_forecasts getting "TypeError: the truth value of a DataFrame is ambiguous", which is most likely doing with the fact that plotly make_subplots parameter subplot_titles is receiving a pl.DataFrame containing the unique entities instead of a list.

import polars as pl
import datetime as dt

y_test = pl.DataFrame({
    "Market": ["CH", "CH", "CH", "DE", "DE", "DE", "US", "US", "US"],
    "Date": [dt.date(2024, 2, 9), dt.date(2024, 2, 10), dt.date(2024, 2, 11),
             dt.date(2024, 2, 9), dt.date(2024, 2, 10), dt.date(2024, 2, 11),
             dt.date(2024, 2, 9), dt.date(2024, 2, 10), dt.date(2024, 2, 11)],
    "Visitors": [26303, 28994, 28781, 26788, 27560, 27039, 28012, 29534, 29007]
})

y_pred = pl.DataFrame({
    "Market": ["CH", "CH", "CH", "DE", "DE", "DE", "US", "US", "US"],
    "Date": [dt.date(2024, 2, 9), dt.date(2024, 2, 10), dt.date(2024, 2, 11),
             dt.date(2024, 2, 9), dt.date(2024, 2, 10), dt.date(2024, 2, 11),
             dt.date(2024, 2, 9), dt.date(2024, 2, 10), dt.date(2024, 2, 11)],
    "Visitors": [26500, 29000, 28800, 26800, 27600, 27100, 28100, 29600, 29100]
})


plot_forecasts(y_true=y_test, y_pred=y_pred, n_series=3)

functime version 0.9.5
plotly version 5.19.0
python version 3.11.4

miroslaavi added a commit to miroslaavi/functime that referenced this issue Mar 3, 2024
Adjusted the subplot position calculation to correctly handle an arbitrary number of series and columns. This change ensures that the grid layout of subplots is dynamically adjusted to accommodate the specified number of series, thus avoiding IndexError and incorrect subplot arrangements.

Fixes functime-org#179
miroslaavi added a commit to miroslaavi/functime that referenced this issue Mar 16, 2024
Adjusted the subplot position calculation to correctly handle an arbitrary number of series and columns. This change ensures that the grid layout of subplots is dynamically adjusted to accommodate the specified number of series, thus avoiding IndexError and incorrect subplot arrangements.

Fixes functime-org#179
@baggiponte baggiponte added bug Something isn't working plotting Plotting features labels Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working plotting Plotting features
Projects
None yet
2 participants