DOC: Replace `@Appender`, `@Substitution`, `@doc` with inlined docstrings
Since pandas has objects with the same API, e.g. DataFrame.fillna Series.fillna, some of these methods may leverage a shared docstring system using @Appender, @Substitution, @doc and variables named like shared_docsto dynamically generate docstring based on a template. While this helps reduce some duplication, the downsides are:
- The shared docstring system, at minimum, adds indirection and, at worse, is less clear than a hardcoded docstring for new contributions
- Since these docstrings are dynamic, they avoid docstring standardization and rules provide by Ruff. (These docstrings are validated by flake8 run in a subprocess, but it would be nice to remove this https://github.com/pandas-dev/pandas/blob/98c9c7f838d223e66f1459fab23ac178b29c2227/scripts/validate_docstrings.py#L203)
The task then is to replace methods that use @Appender, @Substitution or @doc with a hardcoded docstring after the function signature. Since there are many methods that use these decorators, this issue should be completed in multiple PRs ,and therefore, this issue can be worked on by multiple contributors.
For those interested in working on this issue:
- Comment below on which directory you'll be working on, e.g.
fillna - Submit a PR removing the above decorators from the method and inline and docstring substitutions made.
- If a shared docstring is defined on a class inherited by others, e.g.
NDFrame.fillnahas the docstring forSeries.fillnaandDataFrame.fillna, you may need to add language that clarifies application to both e.g.SeriesandDataFrame - If a docstring is not inherited by another object, you can print the
__doc__of a method in a Python terminal and copy-paste that as the new docstring.
- If a shared docstring is defined on a class inherited by others, e.g.
Once all uses of @Appender, @Substitution or @doc are removed, a separate PR to remove these objects would be welcome.
Hi.. I'd like to work on this issue. This will be my first contribution. I'm interested in working on 'dropna' method.
Update: I worked on the groupby method instead of dropna. Found that groupby uses the @Appender decorator in both frame.py and series.py files. I have submitted a PR removing those decorators and replacing them with inline docstrings for 'groupby' DataFrame and Series methods!
take
UPDATES:
- Worked on ExtensionArray.repeat
pandas/core/arrays/base.py - Worked on get_window_bounds
pandas/core/indexers/objects.py - Currently, working on round, floor, ceil of TimelikeOps and strftime of DatelikeOps
pandas\core\arrays\datetimelike.py
“I’ll work on fillna in frame.py and series.py”
If we're going this route, does this render #19932 unnecessary?
If we're going this route, does this render https://github.com/pandas-dev/pandas/issues/19932 unnecessary?
It appears this issue would supersede that issue.
@mroeschke When opening a PR for this issue, would it be better to create one PR per file, per function, or just group them together? Thanks!
take
Will work on removing @Appender and @Substitution on pandas/plotting/_core.py
When opening a PR for this issue, would it be better to create one PR per file, per function, or just group them together?
I would say per function. You can work on multiple functions if one function has few shared docstrings
take
take
take
hello, I will be working on removing @appender from pandas/io/stata.py
edit:
Will also remove @doc from pandas/io/stata.py
I will work on inlining the docstrings and removing @Appender decorators in pandas/core/arrays/interval.py
take - I Will be Working on DataFrame.items()
@mroeschke I think you've closed this issue as a mistake since I've ran ripgrep on the repo and I can still find a couple of @Appender, @Substition and @doc
take
I'd like to work on inlining the docstrings in pandas/core/window/rolling.py
take
I'd like to work on inlining the docstrings in pandas/core/window/expanding.py
take
I'd like to work on inlining the docstrings in pandas\core\generic.py
@mroeschke - have created a PR for DataFrame.groupby - https://github.com/pandas-dev/pandas/pull/62667 Would appreciate your review and any feedback!
I'd like to work on inlining the docstrings in pandas\core\resample.py
I'd also like to work on inlining the docstrings in pandas\core\window\rolling.py
I'd like to work on inlining the docstrings in pandas\core\readers.py
take
Aloha. I'd like to work on replacing doc decorators in pandas/core/series.py with hardcoded docstrings.
take
I would like to work on replacing doc decorators in pandas/core/groupby/generic.py with hardcoded docstrings.
take
I would like to work on replacing doc decorators in pandas/core/indexes/multi.py with hradcoded docstrings
take
I would like to work on replacing doc decorators in pandas/core/indexes/base.py with hardcoded docstrings.
take
I would like to work on replacing doc decorators in pandas/core/indexes/range.py with hardcoded docstrings.
take
I would like to work on replacing doc decorators in pandas/core/arrays/masked.py with hardcoded docstrings.
take
I would like to work on replacing @Appender decorators in pandas/core/indexes/interval.py