You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "js8544 (via GitHub)" <gi...@apache.org> on 2023/06/16 02:54:21 UTC

[GitHub] [arrow] js8544 commented on issue #36118: Inconsistent ordering of descending nulls in `sort_indices` and `rank` functions.

js8544 commented on issue #36118:
URL: https://github.com/apache/arrow/issues/36118#issuecomment-1594017284

   Hi, I think you misunderstood the meaning of `sort_indices`. It returns the sorted array in which each element is represented as their original index. In the example you give, None has index 1 and is placed at the end/start correctly. You can see this if you call `take` on the result:
   ```python
   arr = pa.array(['a', None, 'b'])
   sorted_indices = pc.sort_indices(arr, [('', 'descending')])
   pc.take(arr, sorted_indices)
   
   <pyarrow.lib.StringArray object at 0x7fee5066de40>
   [
     "b",
     "a",
     null
   ]
   ```
   
   ```python
   arr = pa.array(['a', None, 'b'])
   sorted_indices = pc.sort_indices(arr, [('', 'descending')], null_placement='at_start')
   pc.take(arr, sorted_indices)
   
   <pyarrow.lib.StringArray object at 0x7fee98482260>
   [
     null,
     "b",
     "a"
   ]
   ```
   
   The behavior is consistent with rank, i.e. literally at_start and at_end. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org