From 9d5e661959d6389fb3f94d01703e3a22036ef145 Mon Sep 17 00:00:00 2001 From: Samesh Date: Tue, 13 Aug 2019 00:20:01 +0530 Subject: [PATCH 1/3] DOC:Use of "Yields" for documentation of DataFrame.iteritems() changed `Returns` to `Yields` closes #27860 --- pandas/core/frame.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 02241eeaae7b2..1e0a0faeae02f 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -825,7 +825,7 @@ def items(self): for i, k in enumerate(self.columns): yield k, self._ixs(i, axis=1) - @Appender(_shared_docs["items"] % "Returns\n -------") + @Appender(_shared_docs["items"] % "Yields\n -------") def iteritems(self): return self.items() From 3869981781267f9d6dd92ba7aaa1240b72205334 Mon Sep 17 00:00:00 2001 From: Samesh Date: Tue, 13 Aug 2019 17:16:37 +0530 Subject: [PATCH 2/3] MNT:Changed the return method of DataFrame.iteritems changed `return self.items`` --> `yield from self.items()` for better readability and fix doc string failures --- pandas/core/frame.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 1e0a0faeae02f..4e83fd9f1d368 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -827,7 +827,7 @@ def items(self): @Appender(_shared_docs["items"] % "Yields\n -------") def iteritems(self): - return self.items() + yield from self.items() def iterrows(self): """ From c82a6bbd3f807a3055918192bc0dfb1511d7a9df Mon Sep 17 00:00:00 2001 From: Samesh Date: Tue, 13 Aug 2019 17:44:22 +0530 Subject: [PATCH 3/3] edit docstring of iteritems removed placeholder in shared docstring of iteritems and directly changed the main docstring so both of them read `Yields` rather than `Return`. --- pandas/core/frame.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 4e83fd9f1d368..aa59dc5de6896 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -775,7 +775,8 @@ def style(self): Iterates over the DataFrame columns, returning a tuple with the column name and the content as a Series. - %s + Yields + ------ label : object The column names for the DataFrame being iterated over. content : Series @@ -816,7 +817,7 @@ def style(self): Name: population, dtype: int64 """ - @Appender(_shared_docs["items"] % "Yields\n ------") + @Appender(_shared_docs["items"]) def items(self): if self.columns.is_unique and hasattr(self, "_item_cache"): for k in self.columns: @@ -825,7 +826,7 @@ def items(self): for i, k in enumerate(self.columns): yield k, self._ixs(i, axis=1) - @Appender(_shared_docs["items"] % "Yields\n -------") + @Appender(_shared_docs["items"]) def iteritems(self): yield from self.items()