-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Add Series.str
,Series.dt
, and Series.cat
accessors to docs
#8757
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
Conversation
The reason this currently fails is because In summary, you might need to use a custom descriptor like pandas does (this is what we chose in |
Thanks @keewis for taking the time to explain this. After looking through the links you shared, it seems like even with using a custom descriptor (e.g. the pandas example you linked) we still would run into problems, since in Dask the After chatting w/ @ian-r-rose @ncclementi, creating a new auto-documenter class might be an option, where I could get the docstrings from creating a cc @jsignell |
I see what you mean, this does indeed not work with the existing documenters in
While I did consider to instantiate the class in the accessor documenter I never actually tried it because changing the descriptor seemed easier (and I could follow what In any case, feel free to ping me if you need help, and I would also be happy to include those instantiating |
- Refactors the dataframe accessor implementation to define all methods/properties statically on import. This makes it so that methods can be accessed on the class itself, rather than only on instances. - Use a different descriptor for adding the accessor classes to the `Series` class, which lets the accessor methods be accessed via e.g. `dd.Series.str.cat`. - Fix a bug in `dd.Series.str.rsplit` - General cleanliness improvements for the accessor code - Update the api docs to include the accessors (still not quite working)
I've pushed a patch up that refactors our accessor implementation to define all methods/properties statically (and did a bunch of other cleanliness fixes while I was at it). Things are almost working now, but I'm a bit confused what's still broken. Current status:
However, the accessor methods aren't documenting correctly. The accessor property docs are all working perfectly, but the methods show up with no docstring and as data. I'm not sure what the issue is - @keewis do you have any thoughts? |
…3/dask into docs-series-methods
Series.str
,Series.dt
accessors to docsSeries.str
,Series.dt
, and Series.cat
accessors to docs
@jcrist this looks great!!!
I changed the template from |
docs/source/dataframe-api.rst
Outdated
.. autosummary:: | ||
:toctree: generated/ | ||
:template: autosummary/accessor_attribute.rst |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you might have to split this in two parts: one for properties like Series.dt.day
(using the accessor_attribute
template), and another for the methods (using the accessor_method
template).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, nice catch. That's a bit unfortunate that this is needed. Knowing nothing about how sphinx works - is this a sphinx limitation, or is it something that this extension could handle with the same template for both?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's more like that is what pandas
did the last time I checked. It would probably be possible to detect whether the attribute is a descriptor or a method and automatically use the appropriate documenter, but I never really tried.
Edit: I'm not entirely sure, but this seems to work for pandas.Series.cat
Also, at least for the projects I work on the split serves as a reminder that those are called differently (I'm not too familiar with dask.dataframe
, though)
This should be good to go, will merge once tests pass. |
the missing docstring for |
Series.str
/Series.dt
methods missing from Docs #8599pre-commit run --all-files
I added the
Series.str
methods andSeries.dt
accessors todataframe-api.rst
, but am having trouble generating the autosummary. The specific Sphinx warning isWARNING: autosummary: failed to import Series.str.zfill
, e.g., for all newly added lines.I first tried to mimic the pandas docs, copying the changes made in
https://github.com/pandas-dev/pandas/pull/9322
. Then I tried usingsphinx-autosummary-accessors
, which is reflected in this PR. Would very much appreciate ideas/suggestions at this point, I'm not quite sure what else to try!