Skip to content

ENH: Support DataFrame.searchsorted #42872

Open
@ChrisJar

Description

@ChrisJar

Is your feature request related to a problem?

Currently searchsorted is supported for Series and Index objects, however I wish to be able to use it with DataFrame objects as well.

Describe the solution you'd like

I'd like to be able to call DataFrame.searchsorted(value, side, sorter) like in the case of Series.searchsorted, but in this case the value parameter would be a DataFrame with the same number of columns as self.

Additional context

For example:

import pandas as pd

df = pd.DataFrame({'a': [1, 3, 5, 7], 'b': [10, 12, 14, 16]})
value_df = pd.DataFrame({'a': [0, 2], 'b': [10, 11]})
df.searchsorted(value_df)

would return

array([0, 1])

Metadata

Metadata

Assignees

No one assigned

    Labels

    AlgosNon-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diffDataFrameDataFrame data structureEnhancementNeeds DiscussionRequires discussion from core team before further action

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions