-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Preserve original level context in MultiIndex representations #24073
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?
Changes from all commits
7c68b66
87fdf46
026d6d1
63e1e1a
6b6d626
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,6 +39,25 @@ def test_multiindex_repr(pmi, max_seq_items): | |
| assert repr(gmi) == repr(pmi) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("unit", ["s", "ms", "us", "ns"]) | ||
| @pytest.mark.parametrize("tz", [None, "US/Eastern"]) | ||
| @pytest.mark.parametrize("max_seq_items", [None, 2, 10]) | ||
| @pytest.mark.parametrize("selection", [slice(None), slice(0, 1), slice(0, 0)]) | ||
| def test_multiindex_repr_unused_datetime_levels( | ||
| unit, tz, max_seq_items, selection | ||
| ): | ||
| times = pd.date_range("2025-01-01", periods=20, freq="s", tz=tz, unit=unit) | ||
| expected = pd.MultiIndex.from_arrays( | ||
| [pd.CategoricalIndex(["a"] * 10 + ["long label"] * 10), times], | ||
| names=["label", "time"], | ||
|
Comment on lines
+50
to
+52
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Add an all-null level case. The test data has no null values. It does not exercise the changed missing-code conversion to pandas As per coding guidelines, " 🤖 Prompt for AI AgentsSource: Coding guidelines |
||
| ) | ||
| result = cudf.from_pandas(expected)[selection] | ||
| expected = expected[selection] | ||
|
|
||
| with pd.option_context("display.max_seq_items", max_seq_items): | ||
| assert repr(result) == repr(expected) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "gdi, expected_repr", | ||
| [ | ||
|
|
||
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.
🚀 Performance & Scalability | 🟠 Major | 🏗️ Heavy lift
Add a benchmark for full-level conversion.
This path converts every original level even when the preview contains few rows. Add a representation benchmark with high-cardinality unused levels and truncated output. This verifies the cost of the required metadata transfer.
As per coding guidelines, "
**/*: ... 6. Add unit tests and unit benchmarks."🤖 Prompt for AI Agents
Source: Coding guidelines