-
-
Save 0x0L/99de7e12e85ba1ea82f7058e6c73aa85 to your computer and use it in GitHub Desktop.
Sort arrow dictionary arrays
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
| import pyarrow as pa | |
| import pyarrow.compute as pc | |
| def sort_dictionary(arr): | |
| o = pc.sort_indices(arr.dictionary) | |
| return pa.DictionaryArray.from_arrays( | |
| dictionary=pc.take(arr.dictionary, o), | |
| indices=pc.take(pc.sort_indices(o), arr.indices) | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment