From 3d9638219d8da7af334b60d549e92b89f5ccbd97 Mon Sep 17 00:00:00 2001 From: Sean Law Date: Fri, 22 Jul 2016 13:55:45 -0400 Subject: [PATCH 1/2] Fixes issue #13753 - when axis=1 & nrows < ncols --- pandas/core/window.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pandas/core/window.py b/pandas/core/window.py index 9e2a27adc25a7..4621e5f6f2f5d 100644 --- a/pandas/core/window.py +++ b/pandas/core/window.py @@ -1240,10 +1240,10 @@ def _constructor(self): def _get_window(self, other=None): obj = self._selected_obj 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.shape[self.axis], self.min_periods) if self.min_periods + else obj.shape[self.axis]) + return (max((obj.shape[self.axis] + obj.shape[self.axis]), self.min_periods) + if self.min_periods else (obj.shape[self.axis] + obj.shape[self.axis])) @Substitution(name='expanding') @Appender(SelectionMixin._see_also_template) From 5bad8f25a62ae8598aa3d11017d4195c37de21a7 Mon Sep 17 00:00:00 2001 From: Sean Law Date: Fri, 22 Jul 2016 14:05:32 -0400 Subject: [PATCH 2/2] Ensure flake8 compliance --- pandas/core/window.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pandas/core/window.py b/pandas/core/window.py index 4621e5f6f2f5d..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(obj.shape[self.axis], self.min_periods) if self.min_periods - else obj.shape[self.axis]) - return (max((obj.shape[self.axis] + obj.shape[self.axis]), self.min_periods) - if self.min_periods else (obj.shape[self.axis] + obj.shape[self.axis])) + 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)