check_panel_groups_match¶
yohou.utils.validation.check_panel_groups_match(y, X_actual)
¶
Validate that y and X_actual have compatible panel group structures.
When both DataFrames contain panel columns (using the __ separator),
they must share the same entity prefixes. For example, if y has
"store_1__sales" and "store_2__sales", then X_actual must also have
panel columns with "store_1__" and "store_2__" prefixes.
Global-only X_actual (no __ columns) is always valid regardless of y's
structure. Global features are broadcast to every panel group.
Parameters¶
| Name | Type | Description | Default |
|---|---|---|---|
y
|
DataFrame or None
|
Target DataFrame. Can be None. |
required |
X_actual
|
DataFrame or None
|
Feature DataFrame. Can be None. |
required |
Raises¶
| Type | Description |
|---|---|
ValueError
|
If both y and X_actual have panel columns but with different group prefixes, or if y is global but X_actual has panel columns. |
Examples¶
>>> import polars as pl
>>> from datetime import datetime
>>> # Valid: both have same entity prefixes
>>> y = pl.DataFrame({
... "time": [datetime(2020, 1, 1)],
... "store_1__sales": [10],
... "store_2__sales": [20],
... })
>>> X_actual = pl.DataFrame({
... "time": [datetime(2020, 1, 1)],
... "store_1__temp": [100],
... "store_2__temp": [200],
... })
>>> check_panel_groups_match(y, X_actual) # No error
>>> # Valid: panel y with global-only X_actual (broadcast to all groups)
>>> X_global = pl.DataFrame({
... "time": [datetime(2020, 1, 1)],
... "weather": [25.0],
... })
>>> check_panel_groups_match(y, X_global) # No error
>>> # Invalid: different entity prefixes
>>> X_bad = pl.DataFrame({
... "time": [datetime(2020, 1, 1)],
... "sensor_1__temp": [25.0],
... })
>>> check_panel_groups_match(y, X_bad)
Traceback (most recent call last):
...
ValueError: Panel groups mismatch between y and X_actual...
See Also¶
check_panel_internal_consistency: Validate panel groups have consistent structure.check_groups: Validate panel group names for forecaster operations.inspect_panel: Detect panel groups in a DataFrame.
Source Code¶
Show/Hide source
522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 | |