I know you typically select parts of a pd.DataFrame with a boolean mask or via the :
operator. I was wondering whether it is possible to do indexing into a pd.DataFrame using a pd.Interval, i.e. I want to accomplish:
import pandas as pd
df = pd.DataFrame({'A': ['a','b','c','d','e']}) # df has simple RangeIndex(start=0, stop=5, step=1)
interval = pd.Interval(left=1, right=3, closed='both')
print(df[interval]) # I want items 'b','c','d', but get KeyError
So instead I have to go with the more verbose
print(df[interval.left: interval.right])
Indexing via a defined start- and end-point seems like a feature that should be existing, but can't find in the docs. Am I missing something?