rolling-computation Questions

2

Solved

I have got a bug with: x.field.rolling(window=5,min_periods=1).mean() where x is a pandas.core.groupby.groupby.DataFrameGroupBy object. I tried with the solution proposed in this page. So I did t...
Fearfully asked 4/4, 2019 at 13:28

20

Solved

There seems to be no function that simply calculates the moving average on numpy/scipy, leading to convoluted solutions. My question is two-fold: What's the easiest way to (correctly) implement ...

7

Solved

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): p...
Stridulous asked 18/3, 2020 at 9:21

3

I am working on a code that would apply a rolling window to a function that would return multiple columns. Input: Pandas Series Expected output: 3-column DataFrame def fun1(series, ): # Some calcu...
Annamarieannamese asked 3/7, 2020 at 13:34

2

I would like to compute the 1-year rolling average for each row in this Dataframe test: index id date variation 2313 7034 2018-03-14 4.139148e-06 2314 7034 2018-03-13 4.953194e-07 2315 7034 2018-03...
Editorial asked 20/3, 2018 at 15:20

6

Solved

How do I get a column that is the sum of the preceding values of another column?
Sydney asked 9/4, 2011 at 17:19

1

For time-series analysis, it's useful to have rolling PCA functions to analyse how the dynamics of the time-series changes over time to avoid look-ahead bias. We may want to answer the question: 'h...
Unity asked 8/9, 2022 at 16:53

3

Solved

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 si...
Illlooking asked 5/5, 2019 at 9:33

3

Solved

I have labeled event (time series) data where the events occur at random intervals for a given label. I would like to compute the within group ewma and add it to the dataframe as a new column "X1_E...

2

I want to do a rolling computation on missing data. Sample Code: (For sake of simplicity I'm giving an example of a rolling sum but I want to do something more generic.) foo = lambda z: z[pandas....
Rephrase asked 15/11, 2012 at 20:27

2

I'm trying to use the rolling() function on a pandas data frame with monthly data. However, I dropped some NaN values, so now there are some gaps in my time series. Therefore, the basic window para...
Bantamweight asked 5/6, 2018 at 14:48

1

Solved

I would like to get the indexes of the elements in each rolling window of a Pandas Series. A solution that works for me is from this answer to an existing question: I get the window.index for each ...
Genesia asked 11/1, 2022 at 16:21

2

Solved

I am trying to build a scalable method to calculate the number of unique members that have modified a certain file up to and including the latest modified_date. The unique_member_until_now column c...
Oden asked 26/12, 2021 at 18:55

2

Solved

I have some code that is pretty slow, that calculates multiple rolling averages over different time periods (e.g. 3 - 1260 days, or 5 years), but it is very slow and somewhat memory inefficient giv...
Pious asked 12/8, 2021 at 15:3

2

Solved

I have recently come across an interesting question of calculating a vector values using its penultimate value as .init argument plus an additional vector's current value. Here is the sample data s...
Tact asked 28/7, 2021 at 15:48

3

Solved

The data frame contains two variables (time and rate) and 10 observations time <- seq(1:10) rate <- 1-(0.99^time) dat <- data.frame(time, rate) I need to add a new column (called new_rat...
Posterity asked 23/7, 2020 at 0:54

2

Solved

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, 3...
Upbuild asked 24/3, 2021 at 18:54

3

Solved

This is related to R: use the newly generated data in the previous row I realized the actual problem I was faced with is a bit more complicated than the example I gave in the thread above - it seem...
Damal asked 19/4, 2021 at 1:33

3

Solved

I wish to have a fast way to deal with rowwise calculations where values of cells depend on values in previous rows of different columns, prefering vectorization over looping through individual row...
Eliathas asked 13/7, 2021 at 13:38

4

Solved

I have data for one patient in R, which shows dates when they tested positive for a certain condition. The data looks like this: date positive 2005-02-22 yes 2005-04-26 no 2005-08-02 yes 2005-10-0...
Gastroenterostomy asked 10/7, 2021 at 4:40

6

Solved

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,...
Suffering asked 5/10, 2013 at 17:48

2

Solved

Say I have the following dataset dt and a constant constant. dt <- structure(list(var1 = c(-92186.7470607738, -19163.5035325072, -18178.8396858014, -9844.67882723287, -16494.7802822178, -17088...
Invention asked 26/5, 2021 at 14:28

3

Solved

I have a sample dataframe Account Date Amount 10 2020-06-01 100 10 2020-06-11 500 10 2020-06-21 600 10 2020-06-25 900 10 2020-07-11 1000 10 2020-07-15 600 11 2020-06-01 100 11 2020-06-11 200 11 20...
Germano asked 12/4, 2021 at 22:47

5

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 hav...
Hager asked 11/5, 2012 at 1:14

3

I have a datetime series of dtype: float64. I am trying to apply a custom function to a rolling window on the series. I want this function to return strings. However, this generates a TypeError. Wh...
Cowardice asked 24/2, 2021 at 0:12

© 2022 - 2025 — McMap. All rights reserved.