Skip to content

DOC:Use of "Yields" for documentation of DataFrame.iteritems() #27876

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 14, 2019
Merged

DOC:Use of "Yields" for documentation of DataFrame.iteritems() #27876

merged 3 commits into from
Aug 14, 2019

Conversation

sameshl
Copy link
Contributor

@sameshl sameshl commented Aug 12, 2019

changed Returns to Yields

closes #27860

@gfyoung gfyoung added the Docs label Aug 12, 2019
@gfyoung
Copy link
Member

gfyoung commented Aug 12, 2019

@datapythonista @WillAyd : The fix looks good, but the documentation checks seem to be failing.

@jorisvandenbossche jorisvandenbossche added this to the 1.0 milestone Aug 13, 2019
@jorisvandenbossche
Copy link
Member

See the also the discussion on the issue: #27860. Someone will need to understand why the docstring validation sees iteritems and items differently

@jorisvandenbossche
Copy link
Member

Ah, it is because iteritems does return self.items() to do the same, therefore the docstring validation sees 'return' and thinks it needs to return something. See logic in

https://github.com/pandas-dev/pandas/blob/master/scripts/validate_docstrings.py#L529-L562

That's of course a bit brittle. @datapythonista I suppose the easiest here is to ignore that rule?
But currently we can only fully ignore a rule or not in code_checks ?

@datapythonista
Copy link
Member

Since we're Python 3 only now, my preference is to use yield from self.items() instead of return self.items(), and that should fix the doc validation I think.

changed `return self.items`` --> `yield from self.items()`
for better readability and fix doc string failures
@@ -825,9 +825,9 @@ 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 -------")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sameshl you can actually remove this % Yields now, and directly edit this in the docstring above. This was only done so that items and iteritems could have a different title in the docstring (returns vs yields)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh. Nice suggestion @jorisvandenbossche. Will make the required change.

@jorisvandenbossche
Copy link
Member

thanks @datapythonista that indeed seems a good idea

removed placeholder in shared docstring of iteritems and directly changed the
main docstring so both of them read `Yields` rather than `Return`.
Copy link
Member

@datapythonista datapythonista left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, thanks @sameshl

I think it'd probably be cleaner if def items had the docstring directly (just a normal docstring), and def iteritems uses @Appender(DataFrame.items) (I think that's what we use in these cases).

Didn't check in detail if that makes sense for sure, and happy to do that in a follow up PR.

@jorisvandenbossche jorisvandenbossche merged commit 584b154 into pandas-dev:master Aug 14, 2019
@jorisvandenbossche
Copy link
Member

Thanks @sameshl !

@sameshl sameshl deleted the doc_iteritems branch August 15, 2019 02:01
@sameshl
Copy link
Contributor Author

sameshl commented Aug 15, 2019

Glad to help! @jorisvandenbossche

quintusdias pushed a commit to quintusdias/pandas_dev that referenced this pull request Aug 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DOC: Use of "Yields" vs "Returns" for documentation of DataFrame.items() and DataFrame.iteritems()
4 participants