Skip to content

DOC: See also missing links in GroupBy.apply(), GroupBy.pipe() #31661

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

Open
srvanrell opened this issue Feb 4, 2020 · 6 comments
Open

DOC: See also missing links in GroupBy.apply(), GroupBy.pipe() #31661

srvanrell opened this issue Feb 4, 2020 · 6 comments
Assignees
Labels

Comments

@srvanrell
Copy link
Contributor

https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.pipe.html#pandas.core.groupby.GroupBy.pipe

https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.pipe.html#pandas.core.groupby.GroupBy.apply

Problem description

GroupBy.apply() and GroupBy.pipe() have missing links in their See also section. Might be other missing links in other functions of GroupBy.

Specifically, the links that are not working are Series.apply, DataFrame.apply, Series.pipe, DataFrame.pipe

Expected Output

Links should take you to named functions

@srvanrell
Copy link
Contributor Author

srvanrell commented Feb 4, 2020

I would be glad to help but I don't know what is missing. On previous PRs I have solved this kind of issue completing the full signature of the linked function. If anyone can guide me to the solution I can propose a PR.

@alimcmaster1 alimcmaster1 added this to the Contributions Welcome milestone Feb 4, 2020
@srvanrell
Copy link
Contributor Author

Does it has something to do with the Appender decorator?

@Appender(
_apply_docs["template"].format(
input="dataframe", examples=_apply_docs["dataframe_examples"]
)
)
def apply(self, func, *args, **kwargs):
func = self._is_builtin_func(func)
# this is needed so we don't try and wrap strings. If we could
# resolve functions to their callable functions prior, this
# wouldn't be needed
if args or kwargs:
if callable(func):
@wraps(func)
def f(g):
with np.errstate(all="ignore"):
return func(g, *args, **kwargs)
elif hasattr(nanops, "nan" + func):
# TODO: should we wrap this in to e.g. _is_builtin_func?
f = getattr(nanops, "nan" + func)
else:
raise ValueError(
"func must be a callable if args or kwargs are supplied"
)
else:
f = func
# ignore SettingWithCopy here in case the user mutates
with option_context("mode.chained_assignment", None):
try:
result = self._python_apply_general(f)
except TypeError:
# gh-20949
# try again, with .apply acting as a filtering
# operation, by excluding the grouping column
# This would normally not be triggered
# except if the udf is trying an operation that
# fails on *some* columns, e.g. a numeric operation
# on a string grouper column
with _group_selection_context(self):
return self._python_apply_general(f)
return result

@alimcmaster1
Copy link
Member

@datapythonista @jorisvandenbossche - I think this affects quite alot of the Docstrings in pandas.core.

Other examples where See Also links do not have a href would be (in addition to the above):

Resampler.aggregate and Resampler.asfreq. They cannot reference attributes in the top level pandas namespace. Whereas Resampler.interpolate looks fine.

One fix would be to update:

See Also
--------
DataFrame.pipe: Apply a function with arguments to a dataframe.

to

See Also
--------
pandas.DataFrame.pipe: Apply a function with arguments to a dataframe.

Wanted to get your thoughts on this as we don't do it elsewhere?

@alimcmaster1 alimcmaster1 self-assigned this Feb 5, 2020
@datapythonista
Copy link
Member

I think we should understand the problem instead of prefixing with pandas. Something must be wrong with sphinx. Afaik it saves all the pages first, and then uses that to generate the links.

Besides debugging that, we can check if it also fails with other versions of sphinx.

@srvanrell
Copy link
Contributor Author

Another example of the same issue? DataFrame.aggregate

@mroeschke mroeschke removed this from the Contributions Welcome milestone Oct 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants