Assuming you have a dataframe df
with numeric values and you want to take the average of each 12 values, you could use the rolling
function in pandas to create a rolling window with a size of 12 and then take the mean
of each window. The resulting dataframe will have NaN
values for the first 11 rows, since there won't be enough values to fill the rolling window at the start. Here's an example code snippet:
main.py700 chars36 lines
gistlibby LogSnag