diff --git a/pandas/core/window.py b/pandas/core/window.py index 9e2a27adc25a7..7b305da73a443 100644 --- a/pandas/core/window.py +++ b/pandas/core/window.py @@ -1239,11 +1239,12 @@ def _constructor(self): def _get_window(self, other=None): obj = self._selected_obj + obj_len = obj.shape[self.axis] if other is None: - return (max(len(obj), self.min_periods) if self.min_periods - else len(obj)) - return (max((len(obj) + len(obj)), self.min_periods) - if self.min_periods else (len(obj) + len(obj))) + return (max(obj_len, self.min_periods) if self.min_periods + else obj_len) + return (max((obj_len + obj_len), self.min_periods) + if self.min_periods else (obj_len + obj_len)) @Substitution(name='expanding') @Appender(SelectionMixin._see_also_template)