Implement cudf.MultiIndex.from_arrays - #14740
Merged
rapids-bot[bot] merged 5 commits intoJan 18, 2024
Merged
Conversation
isVoid
reviewed
Jan 12, 2024
| """ | ||
| Convert arrays to MultiIndex. | ||
|
|
||
| Parameters |
Contributor
There was a problem hiding this comment.
Missing sortorder docstring in parameters.
Contributor
Author
There was a problem hiding this comment.
Good catch. Added
|
|
||
| @pytest.mark.parametrize( | ||
| "array", | ||
| [list, tuple, np.array, pd.Index, cudf.Index, pd.Series, cudf.Series], |
Contributor
There was a problem hiding this comment.
Should we also test cupy arrays?
Comment on lines
+1481
to
+1486
| for array in arrays: | ||
| if not (is_list_like(array) or is_column_like(array)): | ||
| raise TypeError(error_msg) | ||
| code, level = factorize(array, sort=True) | ||
| codes.append(code) | ||
| levels.append(level) |
Contributor
There was a problem hiding this comment.
As a functional exercise, this can rewrite as a map statement:
code_levels = map(functools.partial(factorize, sort=True), array)
codes, levels = [x[0] for x in code_levels], [x[1] for x in code_levels]Error checking is also functional:
if not all (is_list_like(arr) or is_column_like(arr) for arr in arrays):
raise TypeError(error_msg)
Contributor
Author
There was a problem hiding this comment.
Ya my idea was just to do the validation + factorization in the same loop
isVoid
approved these changes
Jan 18, 2024
Contributor
Author
|
/merge |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Implements
cudf.MultiIndex.from_arraysChecklist