## Resolved: How to calculate the correlation coefficient on a rolling window of a vector using numpy?

In this post, we will see how to resolve How to calculate the correlation coefficient on a rolling window of a vector using numpy? Question: I’m able to calculate a rolling correlation coefficient for a 1D-array (data against [0, 1, ...

## Resolved: Conduct rolling regression in windows of 5 years for each group in R

In this post, we will see how to resolve Conduct rolling regression in windows of 5 years for each group in R Question: I have data with variables industry_sales, year, and industry. I want to conduct time series regressions for ...

## Resolved: Pandas dataframe get expanding/rolling value counts

Question: Is it possible to create value counts for a series in a cumulative/expanding fashion? E.g. for the following series pd.Series(['a', 'a', 'b', 'c', 'c']) I’d want Best Answer: Encode the series into indicator variables and use cumsum If you ...

## Resolved: Rolling count unique in dataframe’s rows or ndarray

Question: Given a dataframe df, how to calculate the rolling count of unique values through rows’ direction subject to a boundary condition: window size = n? Input data: Expected output (with window size = 2): For the example above with ...

## Resolved: Sum of rolling groupby based on date not returning expected results

Question: I have the following DataFrame: I would like to get the sum of player__match_count__won for a rolling 30 day period grouped by player ID excluding the current row in the rolling window. I’m using the below to return a ...

## Resolved: I am new, trying to roll 3d6, rerolling 1’s, and put them into a list. I cant seem to get 3 “new” values in the list. The numbers just keep adding up

Question: I am not sure how to get 3 distinct entries in my list, just keeps adding up. Answer: Your code currently rolls a die 3 times, adding the results if the roll is not 1, otherwise rerolling the die ...

## Resolved: Pandas Rolling value_counts() [duplicate]

Question: I am looking for a way in pandas to return the specific value_counts() over a rolling time window. I found the following question (pandas `value_counts` on a rolling time window), but it’s not quite what I would like. If ...

## Resolved: Datetime rolling count per category in Pandas

Question: Starting from a DataFrame with a date and user column, I’d like to add a third count_past_5_days column to indicate the rolling count of occurrences of each row’s user during the past 5 days: date user count_past_5_days 2020-01-01 abc ...