Getting all weekends between two dates in Pandas
Start your free 7-days trial now!
To get all weekends between two dates, use Pandas
DatetimeIndex(['2020-12-19', '2020-12-20', '2020-12-26'], dtype='datetime64[ns]', freq='C')
Note the following:
freq="C", which stands for custom business day, is required whenever we specify
bdate_range(~)returns weekdays (the prefix
bstands for business), and so we override this by specifying our own
closed="right", which means that the start date is exclusive, while the end date is inclusive.