Group by business day of month

Question:

Data generated only on business days.

df['Day_of_Month'] = df.index.day
Date........................................                                   Day_of_Month
2014-11-26   1049.25     1054.75        26
2014-11-28   1041.00     1051.50        28
2014-12-01   1010.75     1022.50        1

Can group by calendar day of month,’Day_of_Month’, approx 30 per month

Goal is to group by business day of month, approx 22/month

Is there df.index.buiness_day_of_Month type function?

Tried importing BDay, special calendars and like, without success. Thank you for your help.

Asked By: Rayl54292

||

Answers:

May be this helps

dat1$grp <- with(dat1, ave(seq_along(Date1), 
           format(Date1, '%m'), FUN=seq_along))
aggregate(Val~grp, dat1, FUN=sum)

data

Date <- seq(as.Date('2014-11-01'), length.out=80, by='1 day')
library(timeDate)
Date1 <- Date[isBizday(as.timeDate(Date))]
Day_of_Month <-  as.numeric(format(Date1, '%d'))
set.seed(24)
dat1 <- data.frame(Date1, Day_of_Month, Val=rnorm(54))
Answered By: akrun
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.