Skip to content

QST: Dataframe filter a column if it is in an interval data type #52616

@davetapley

Description

@davetapley

Research

  • I have searched the [pandas] tag on StackOverflow for similar questions.

  • I have asked my usage related question on StackOverflow.

Link to question on StackOverflow

https://stackoverflow.com/questions/55832639/dataframe-filter-a-column-if-it-is-in-an-interval-data-type

Question about pandas

Top voted SO answer gives:

data.loc[(data.A>=interval.left) & (data.A<interval.right)]

But this doesn't account for interval.closed.
Obviously that snippet could be expanded but check, but I feel like this should be supported out of the box?


IntervalIndex feels like it's close, but this restriction makes it a no-go for my case:

intervals that are closed on the same side.


Related: #21998

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs TriageIssue that has not been reviewed by a pandas team memberUsage Question

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions