Skip to main content
Ctrl+K
cudf 25.04.00 documentation - Home cudf 25.04.00 documentation - Home
  • cuDF User Guide
  • cudf.pandas
  • Polars GPU engine
  • pylibcudf documentation
  • libcudf documentation
    • Developer Guide
  • GitHub
  • Twitter
Home
cudf
cucimcudf-javacudfcugraphcumlcuprojcuspatialcuvscuxfilterdask-cudadask-cudfkvikiolibcudflibcumllibcuprojlibcuspatiallibkvikiolibrmmlibucxxraftrapids-cmakermm
stable (25.04)
nightly (25.06)stable (25.04)legacy (25.02)
  • cuDF User Guide
  • cudf.pandas
  • Polars GPU engine
  • pylibcudf documentation
  • libcudf documentation
  • Developer Guide
  • GitHub
  • Twitter

Section Navigation

Contents:

  • libcudf documentation
    • libcudf
    • Default Stream
    • Memory Resource Management
    • Cudf Classes
      • Column Classes
        • Column Factories
        • Dictionary Classes
        • Lists Classes
        • Strings Classes
        • Structs Classes
        • Timestamp Classes
      • Table Classes
      • Scalar Classes
        • Scalar Factories
      • Fixed Point Classes
    • Column APIs
      • Column Copy
        • Copy Concatenate
        • Copy Gather
        • Copy Scatter
        • Copy Slice
        • Copy Split
        • Copy Shift
      • Column Nullmask
      • Column Sort
      • Column Search
      • Column Hash
      • Column Merge
      • Column Join
      • Column Quantiles
      • Column Aggregation
        • Aggregation Factories
        • Aggregation Reduction
        • Aggregation Groupby
        • Aggregation Rolling
      • Column Transformation
        • Transformation Unaryops
        • Transformation Binaryops
        • Transformation Transform
        • Transformation Replace
        • Transformation Fill
      • Column Reshape
        • Reshape Transpose
      • Column Reorder
        • Reorder Partition
        • Reorder Compact
      • Column Interop
        • Interop Dlpack
        • Interop Arrow
    • Datetime APIs
      • Datetime Extract
      • Datetime Compute
    • Strings APIs
      • Strings Case
      • Strings Types
      • Strings Combine
      • Strings Contains
      • Strings Convert
      • Strings Copy
      • Strings Slice
      • Strings Find
      • Strings Modify
      • Strings Replace
      • Strings Split
      • Strings Extract
      • Strings Regex
    • Dictionary APIs
      • Dictionary Encode
      • Dictionary Search
      • Dictionary Update
    • Io APIs
      • Io Types
      • Io Readers
      • Io Writers
      • Io Datasources
      • Io Datasinks
    • JSON APIs
      • JSON Object
    • Lists APIs
      • Lists Combine
      • Lists Modify
      • Lists Extract
      • Lists Filling
      • Lists Contains
      • Lists Gather
      • Lists Elements
      • Lists Filtering
      • Lists Sort
      • Set Operations
    • Nvtext APIs
      • Nvtext Ngrams
      • Nvtext Normalize
      • Nvtext Stemmer
      • Nvtext Edit Distance
      • Nvtext Tokenize
      • Nvtext Replace
      • Nvtext Minhash
      • Nvtext Jaccard
    • Utility APIs
      • Utility Types
      • Utility Dispatcher
      • Utility Bitmask
      • Utility Error
      • Utility Span
    • Labeling APIs
      • Label Bins
    • Expression Evaluation
    • tdigest
  • Regex Features
  • Unicode Limitations
  • libcudf documentation
  • libcudf documentation
  • Column APIs
  • Column Search

Column Search#

group Searching

Functions

std::unique_ptr<column> lower_bound(table_view const &haystack, table_view const &needles, std::vector<order> const &column_order, std::vector<null_order> const &null_precedence, rmm::cuda_stream_view stream = cudf::get_default_stream(), rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref())#

Find smallest indices in a sorted table where values should be inserted to maintain order.

For each row in needles, find the first index in haystack where inserting the row still maintains its sort order.

Example:

 Single column:
     idx        0   1   2   3   4
  haystack = { 10, 20, 20, 30, 50 }
  needles  = { 20 }
  result   = {  1 }

 Multi Column:
     idx          0    1    2    3    4
  haystack = {{  10,  20,  20,  20,  20 },
              { 5.0,  .5,  .5,  .7,  .7 },
              {  90,  77,  78,  61,  61 }}
  needles  = {{ 20 },
              { .7 },
              { 61 }}
  result   = {   3 }
Parameters:
  • haystack – The table containing search space

  • needles – Values for which to find the insert locations in the search space

  • column_order – Vector of column sort order

  • null_precedence – Vector of null_precedence enums needles

  • stream – CUDA stream used for device memory operations and kernel launches

  • mr – Device memory resource used to allocate the returned column’s device memory

Returns:

A non-nullable column of elements containing the insertion points

std::unique_ptr<column> upper_bound(table_view const &haystack, table_view const &needles, std::vector<order> const &column_order, std::vector<null_order> const &null_precedence, rmm::cuda_stream_view stream = cudf::get_default_stream(), rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref())#

Find largest indices in a sorted table where values should be inserted to maintain order.

For each row in needles, find the last index in haystack where inserting the row still maintains its sort order.

Example:

 Single Column:
     idx        0   1   2   3   4
  haystack = { 10, 20, 20, 30, 50 }
  needles  = { 20 }
  result   = {  3 }

 Multi Column:
     idx          0    1    2    3    4
  haystack = {{  10,  20,  20,  20,  20 },
              { 5.0,  .5,  .5,  .7,  .7 },
              {  90,  77,  78,  61,  61 }}
  needles  = {{ 20 },
              { .7 },
              { 61 }}
  result =     { 5 }
Parameters:
  • haystack – The table containing search space

  • needles – Values for which to find the insert locations in the search space

  • column_order – Vector of column sort order

  • null_precedence – Vector of null_precedence enums needles

  • stream – CUDA stream used for device memory operations and kernel launches

  • mr – Device memory resource used to allocate the returned column’s device memory

Returns:

A non-nullable column of elements containing the insertion points

bool contains(column_view const &haystack, scalar const &needle, rmm::cuda_stream_view stream = cudf::get_default_stream())#

Check if the given needle value exists in the haystack column.

Single Column:
 idx           0   1   2   3   4
 haystack = { 10, 20, 20, 30, 50 }
 needle   = { 20 }
 result   = true

Throws:

cudf::logic_error – If haystack.type() != needle.type().

Parameters:
  • haystack – The column containing search space

  • needle – A scalar value to check for existence in the search space

  • stream – CUDA stream used for device memory operations and kernel launches

Returns:

true if the given needle value exists in the haystack column

std::unique_ptr<column> contains(column_view const &haystack, column_view const &needles, rmm::cuda_stream_view stream = cudf::get_default_stream(), rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref())#

Check if the given needles values exists in the haystack column.

The new column will have type BOOL and have the same size and null mask as the input needles column. That is, any null row in the needles column will result in a nul row in the output column.

haystack = { 10, 20, 30, 40, 50 }
needles  = { 20, 40, 60, 80 }
result   = { true, true, false, false }

Throws:

cudf::logic_error – If haystack.type() != needles.type()

Parameters:
  • haystack – The column containing search space

  • needles – A column of values to check for existence in the search space

  • stream – CUDA stream used for device memory operations and kernel launches

  • mr – Device memory resource used to allocate the returned column’s device memory

Returns:

A BOOL column indicating if each element in needles exists in the search space

previous

Column Sort

next

Column Hash

On this page
  • lower_bound()
  • upper_bound()
  • contains()
  • contains()

This Page

  • Show Source

© Copyright 2018-2025, NVIDIA Corporation.

Created using Sphinx 8.2.3.

Built with the PyData Sphinx Theme 0.16.1.