panda get rows with date range 1

panda get rows with date range

#greater than the start date and smaller than the end date
mask = (df['date'] > start_date) & (df['date'] <= end_date)
df = df.loc[mask]

Here is what the above code is Doing:
1. We're creating a mask that is true when the date is greater than the start date and less than the end date.
2. We're using the mask to filter the dataframe.

Similar Posts