Python Pandas rolling functions

后端 未结 2 1430
灰色年华
灰色年华 2021-01-15 02:35

I am not sure I understand the parameter min_periods in Pandas rolling functions : why does it have to be smaller than the window para

2条回答
  •  执笔经年
    2021-01-15 03:10

    the min_period = n option simply means that you require at least n valid observations to compute your rolling stats.

    Example, suppose min_period = 5 and you have a rolling mean over the last 10 observations. Now, what happens if 6 of the last 10 observations are actually missing values? Then, given that 4<5 (indeed, there are only 4 non-missing values here and you require at least 5 non-missing observations), the rolling mean will be missing as well.

    It's a very, very important option.

    From the documentation

    min_periods : int, default None Minimum number of observations in window required to have a value (otherwise result is NA).

提交回复
热议问题