-
-
Notifications
You must be signed in to change notification settings - Fork 19.1k
Closed
Labels
DatetimeDatetime data dtypeDatetime data dtypeEnhancementIndexRelated to the Index class or subclassesRelated to the Index class or subclassesNeeds DiscussionRequires discussion from core team before further actionRequires discussion from core team before further action
Description
Feature Type
-
Adding new functionality to pandas
-
Changing existing functionality in pandas
-
Removing existing functionality in pandas
Problem Description
I would like to use Series#between
on DatetimeIndex
instances. Presumably this could also be extended to other Index types, but I am specifically only considering the DatetimeIndex case
Feature Description
import pandas as pd
t = pd.Timestamp.today()
ser = pd.Series(range(10), index=pd.date_range(t, periods=10))
ser.loc[ser.between(t, t + pd.offsets.BDay(1))]
Alternative Solutions
import pandas as pd
t = pd.Timestamp.today()
ser = pd.Series(range(10), index=pd.date_range(t, periods=10))
# current option 1
ser.loc[(ser.index >= t) & (ser.index <= t + pd.offsets.BDay(1))]
# current option 2
ser.loc[ser.index.to_series().between(t, t + pd.offsets.BDay(1))]
Additional Context
Purely convenience method / addition. Presumably could also be extended to the related between_time
method.
Metadata
Metadata
Assignees
Labels
DatetimeDatetime data dtypeDatetime data dtypeEnhancementIndexRelated to the Index class or subclassesRelated to the Index class or subclassesNeeds DiscussionRequires discussion from core team before further actionRequires discussion from core team before further action