Skip to content

Commit 3775699

Browse files
committed
use f-string for attrs_list in __repr__ in pandas/core/window/rolling.py
1 parent d385f6e commit 3775699

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

pandas/core/window/rolling.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -211,14 +211,13 @@ def __repr__(self) -> str:
211211
Provide a nice str repr of our rolling object.
212212
"""
213213

214-
attrs = (
215-
"{k}={v}".format(k=k, v=getattr(self, k))
216-
for k in self._attributes
217-
if getattr(self, k, None) is not None
218-
)
219-
return "{klass} [{attrs}]".format(
220-
klass=self._window_type, attrs=",".join(attrs)
214+
attrs_list = (
215+
f"{attr_name}={getattr(self, attr_name)}"
216+
for attr_name in self._attributes
217+
if getattr(self, attr_name, None) is not None
221218
)
219+
attrs = ",".join(attrs_list)
220+
return "{klass} [{attrs}]".format(klass=self._window_type, attrs=attrs)
222221

223222
def __iter__(self):
224223
url = "https://github.com/pandas-dev/pandas/issues/11704"

0 commit comments

Comments
 (0)