-
Notifications
You must be signed in to change notification settings - Fork 2k
doc: Improve documentation for decimation on datetime axis #2754
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: develop
Are you sure you want to change the base?
Conversation
|
This PR has been labelled as "🥶Waiting for contributor" because it has been inactive for more than 14 days. If you would like to continue working on this PR, then please add new commit or another comment, otherwise this PR will be closed in 14 days. For more information please refer to the contributing guidelines. |
|
This PR has been labelled as "🥶Waiting for contributor" because it has been inactive for more than 14 days. If you would like to continue working on this PR, then please add new commit or another comment, otherwise this PR will be closed in 14 days. For more information please refer to the contributing guidelines. |
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.
Pull request overview
This PR aims to improve documentation by adding an example demonstrating how to use decimators with datetime data on the x-axis. However, the implementation contains a fundamental misunderstanding of how the MinMaxDecimator processes DataFrame columns.
Key Issues:
- The example incorrectly assumes the decimator always uses the first two DataFrame columns (
data[:, 0]anddata[:, 1]) - In reality, the decimator uses the columns specified by the chart's
xandyparameters - The current implementation will cause the decimator to operate on datetime objects rather than numeric values
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| start_time = datetime.now() | ||
| timestamps = [start_time + pd.Timedelta(seconds=x) for x in x_values] | ||
|
|
||
| data = pd.DataFrame({"X_numeric": x_values, "Y": y_values_noise, "X_datetime": timestamps}) |
Copilot
AI
Nov 25, 2025
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.
The DataFrame structure shown here will not work as described in the comments. The decimator uses the columns specified by the chart's x and y parameters (line 56: x="X_datetime"), not the first two columns.
Since x="X_datetime" is specified, the decimator will attempt to use the X_datetime column (datetime values) for the x-axis in its algorithm, not X_numeric. This means the MinMax algorithm will operate on datetime objects rather than numeric values, which is likely not the intended behavior and may cause errors or unexpected results.
| """ | ||
| Example demonstrating proper use of decimators with datetime data. | ||
|
|
||
| This example shows how to handle datetime data with MinMaxDecimator by using | ||
| numeric x-axis values while keeping datetime information separate. | ||
| """ |
Copilot
AI
Nov 25, 2025
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.
The docstring description is misleading. It states "using numeric x-axis values while keeping datetime information separate," but the actual implementation uses x="X_datetime" in the chart configuration (line 56), which means the decimator algorithm will receive datetime values, not numeric values.
The current approach does not demonstrate "proper use of decimators with datetime data" because the decimator will attempt to perform numeric operations (like reshaping and finding min/max) on datetime objects based on the specified x column.
| # How to decimate datetime data? - Structure data for decimation algorithm: | ||
| # Column 0: Numeric values for decimation algorithm (data[:, 0]) | ||
| # Column 1: Y values (data[:, 1]) | ||
| # Column 2: DateTime values for x-axis display (data[:, 2]) |
Copilot
AI
Nov 25, 2025
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.
The comment incorrectly describes how the decimator algorithm works. The decimator does not automatically use data[:, 0] and data[:, 1] based on DataFrame column order. Instead, it uses the columns specified by the chart's x and y parameters.
In this example, since x="X_datetime" is set on line 56, the decimator will extract X_datetime (datetime values) and Y columns, convert them to a numpy array, and then apply the MinMax algorithm. This means the decimator will try to perform numeric operations on datetime objects, which may not work as intended.
The X_numeric column is never used by the decimator in this configuration. If the goal is to decimate based on numeric values while displaying datetime on the x-axis, this approach will not work as described.
| # How to decimate datetime data? - Structure data for decimation algorithm: | |
| # Column 0: Numeric values for decimation algorithm (data[:, 0]) | |
| # Column 1: Y values (data[:, 1]) | |
| # Column 2: DateTime values for x-axis display (data[:, 2]) | |
| # How to decimate datetime data? | |
| # The decimator uses the columns specified by the chart's `x` and `y` parameters. | |
| # In this example, since `x="X_datetime"` is set, the decimator will operate on datetime values, | |
| # which may not work as intended for numeric decimation. If you want to decimate based on numeric values, | |
| # set `x="X_numeric"` and handle datetime display separately. |
|
This PR has been labelled as "🥶Waiting for contributor" because it has been inactive for more than 14 days. If you would like to continue working on this PR, then please add new commit or another comment, otherwise this PR will be closed in 14 days. For more information please refer to the contributing guidelines. |
What type of PR is this? (Check all that apply)
Description
Adds an example of decimating data where we want to display a datetime axis. The idea is that the
MinMaxDecimatortakes the first and second column of the dataframe asxandyaxes:But it's possible to just set a different column as X axis marks. (Please correct me if my understanding isn't correct :)
Related Tickets & Documents
How to reproduce the issue
N/A - it's just a docs update, but feel free to run the included example file as well.
Backporting
This change should be backported to:
Checklist
We encourage keeping the code coverage percentage at 80% or above.
If not, explain why: docs only
If not, explain why: docs only
If not, explain why:
If not, explain why: handled by maintainers?