- Notifications
You must be signed in to change notification settings - Fork 1
Add plot_waterfall helper for dataframe-based waterfall charts#93
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
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
047dbfd0d5d398eb76c60f34b7a6f79dc95bbdac4090a5382ac74fcec22383ec0c69a6f72a23fFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -2,6 +2,7 @@ | ||||||
| import os | ||||||
| import re | ||||||
| from pathlib import Path | ||||||
| from typing import Optional, Tuple | ||||||
| from urllib.parse import urlparse, unquote | ||||||
| import pandas | ||||||
| @@ -46,3 +47,81 @@ def read_csv_cached( | ||||||
| df = pandas.read_csv(filepath_or_buffer, **kwargs) | ||||||
| df.to_csv(cache_name, index=False) | ||||||
| return df | ||||||
| def plot_waterfall( | ||||||
| data: pandas.DataFrame, | ||||||
| value_column: str, | ||||||
| label_column: Optional[str] = None, | ||||||
| total_label: str = "total", | ||||||
| ax=None, | ||||||
| colors: Tuple[str, str, str] = ("#2ca02c", "#d62728", "#1f77b4"), | ||||||
| ): | ||||||
| """ | ||||||
| Draws a waterfall chart from a dataframe. | ||||||
| :param data: dataframe containing increments | ||||||
| :param value_column: column with increments | ||||||
| :param label_column: column with labels, index is used if None | ||||||
| :param total_label: label used for the final total | ||||||
| :param ax: existing axis or None to create one | ||||||
| :param colors: positive, negative, total colors | ||||||
| :return: axis, computed dataframe used to draw the chart | ||||||
| .. versionadded:: 0.6.1 | ||||||
CopilotAI | ||||||
| .. versionadded:: 0.6.1 | |
| .. versionadded:: 0.6.0 |
Uh oh!
There was an error while loading. Please reload this page.
CopilotAIApr 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
plot_waterfallcreates a new Matplotlib figure whenax is None, and this unit test will exercise that path. In headless CI environments, importing/usingmatplotlib.pyplotcan fail or pick an interactive backend unless a non-interactive backend (e.g., Agg) is forced by the test runner/environment. Consider explicitly forcing a non-interactive backend for this test suite (or in this test) and closing the created figure to avoid accumulating open figures across tests.