Let's say the eventDate column contains all days for September:
import pandas as pd
df = pd.DataFrame({
"eventDate": pd.date_range(start="2022-09-01", end="2022-09-30").strftime('%Y-%m-%d'),
})
And you want the dates to be "valid" only for the first week of September. You could do it this way:
from datetime import datetime
d1 = datetime(year=2022, month=9, day=1) # first day valid
d2 = datetime(year=2022, month=9, day=7) # last day valid
def is_date_valid(str_date: str):
dt = datetime.fromisoformat(str_date)
return ((dt >= d1) and (dt <= d2))
df["validDate"] = df["eventDate"].apply(is_date_valid)
The result you get:
df.head(10)
eventDate validDate
0 2022-09-01 True
1 2022-09-02 True
2 2022-09-03 True
3 2022-09-04 True
4 2022-09-05 True
5 2022-09-06 True
6 2022-09-07 True
7 2022-09-08 False
8 2022-09-09 False
9 2022-09-10 False