# How to detect calendar effects for stock prices (day-of-week, month, etc.)

This is a python/pandas question just as much as it is a statistical one.

How would I go about determining the typical delta for day-of-week and month effects of a given time series?

Taking the day-of-week effect as an example, so far I've written:

# Where data are close prices of a given symbol on a daily timeframe
# 1. Find change between prior day and given day
# 2. Group those changes by weekday
# 3. Find the mode (most common rate of change)
# 4. Normalize the weekday deltas to one another
deltas = data.diff().groupby(data.index.weekday).agg(lambda x: pd.Series.mode(x)[0])
delta_min = deltas.min()
dayofweek = 2 * ((delta - delta_min) / (delta.max() - delta_min)) - 1


I can already tell right off the bat that my code isn't accounting for monthly/yearly changes which is what I need help on (not accounting for these changes will skew the results). I also want to do this for month effects but I figure the solution will be similar to solving for day-of-week.