Skip to main content
253 votes
22 answers
474k views

There doesn’t seem to be any function in NumPy or SciPy that simply calculate the moving average, leading to convoluted solutions. My question is twofold: What's the easiest way to (correctly) ...
loopbackbee's user avatar
  • 23.6k
119 votes
9 answers
211k views

I've got a bunch of polling data; I want to compute a Pandas rolling mean to get an estimate for each day based on a three-day window. According to this question, the rolling_* functions compute the ...
Anov's user avatar
  • 2,321
24 votes
7 answers
33k views

I have the following vector: x = c(1, 2, 3, 10, 20, 30) At each index, 3 consecutive elements are summed, resulting in the following vector: c(6, 15, 33, 60) Thus, first element is 1 + 2 + 3 = 6, ...
user2834313's user avatar
90 votes
5 answers
167k views

I have a time series object grouped of the type <pandas.core.groupby.SeriesGroupBy object at 0x03F1A9F0>. grouped.sum() gives the desired result but I cannot get rolling_sum to work with the ...
user avatar
41 votes
7 answers
51k views

I am trying to use a pandas.DataFrame.rolling.apply() rolling function on multiple columns. Python version is 3.7, pandas is 1.0.2. import pandas as pd #function to calculate def masscenter(x): ...
Suthiro's user avatar
  • 1,300
19 votes
3 answers
7k views

I am looking for some performance gains in terms of rolling/sliding window functions in R. It is quite common task which can be used in any ordered observations data set. I would like to share some of ...
jangorecki's user avatar
  • 16.8k
8 votes
2 answers
29k views

My imported data contains 7 variables: Y and X1, X2, X3, X4, X5, X6. I tried applying the rollapply function in zoo in order to run a rolling regression within an in-sample with a window of 262 obs. (...
user3546838's user avatar
0 votes
1 answer
2k views

I have a Pandas dataframe with some data on race car drivers. The relevant columns look like this: |Date |Name |Distance |avg_speed_calc |---- |---- |---- |---- |9/6/...
AMJ's user avatar
  • 33
17 votes
5 answers
36k views

I have a data set of email addresses and dates that those email addresses were added to a table. There can be multiple entries of an email address for various different dates. For example, if I have ...
harold's user avatar
  • 171
3 votes
2 answers
417 views

The dataset named crass looks like - > dput(crass) structure(list(WT_TRADE_PRICE = c(3801, 3801, 3801, 3797, 3797, 3796.2125, 3800, 3797, 3795.09523809524, 3794, 3793, 3793, 3793.8, 3794.72, 3793....
shoonya's user avatar
  • 311
11 votes
3 answers
8k views

I want to apply a function to a rolling window. All the answers I saw here are focused on applying to a single row / column, but I would like to apply my function to the entire window. Here is a ...
Yair Daon's user avatar
  • 1,163
3 votes
3 answers
18k views

Initial problem statement Using pandas, I would like to apply function available for resample() but not for rolling(). This works: df1 = df.resample(to_freq, closed='left', ...
pierre_j's user avatar
  • 1,003
3 votes
2 answers
714 views

Let's say we have 3 variables a, b & c. There are n instances of each, and all but the first instance of c are null. We are to calculate each next c based on a given formula comprising of only ...
mindoverflow's user avatar
0 votes
1 answer
794 views

I have a pandas DataFrame with date as the index and a column, 'spendings'. I intend to get the rolling max() of the 'spendings' column for the trailing 1 calendar month (not 30 days or 4 weeks). I ...
Ethan's user avatar
  • 5,015
10 votes
4 answers
4k views

There are many questions about rolling regression in R, but here I am specifically looking for something that uses dplyr, broom and (if needed) purrr. This is what makes this question different. I ...
ℕʘʘḆḽḘ's user avatar

15 30 50 per page
1
2 3 4 5
9