Skip to content
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

docs: use type hints + from_native/to_native in series.py #1408

Merged
merged 1 commit into from
Nov 20, 2024

Conversation

MarcoGorelli
Copy link
Member

@MarcoGorelli MarcoGorelli commented Nov 20, 2024

Start updating more docstrings, pending discussion in #1407

What type of PR is this? (check all applicable)

  • πŸ’Ύ Refactor
  • ✨ Feature
  • πŸ› Bug Fix
  • πŸ”§ Optimization
  • πŸ“ Documentation
  • βœ… Test
  • 🐳 Other

Related issues

  • Related issue #<issue number>
  • Closes #<issue number>

Checklist

  • Code follows style guide (ruff)
  • Tests added
  • Documented the changes

If you have comments or can explain your changes, please do so below

@github-actions github-actions bot added the documentation Improvements or additions to documentation label Nov 20, 2024
@MarcoGorelli MarcoGorelli marked this pull request as ready for review November 20, 2024 09:27
Comment on lines -1585 to +1595
>>> def my_library_agnostic_function(s_native: IntoSeriesT) -> IntoSeriesT:
>>> def agnostic_sort(s_native: IntoSeriesT) -> IntoSeriesT:
... s = nw.from_native(s_native, series_only=True)
... return s.sort().to_native()

>>> @nw.narwhalify
... def func_descend(s):
>>> def agnostic_sort_descending(s_native: IntoSeriesT) -> IntoSeriesT:
... s = nw.from_native(s_native, series_only=True)
... return s.sort(descending=True).to_native()

We can then pass either pandas or Polars to `func`:
We can then pass either pandas or Polars to `agnostic_sort`:

>>> my_library_agnostic_function(s_pd)
>>> agnostic_sort(s_pd)
Copy link
Member Author

Choose a reason for hiding this comment

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

πŸ€” ok i do like the way this looks...nice one @FBruzzesi

Copy link
Member

Choose a reason for hiding this comment

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

Thanks! I like it as well! Drawback is... a bit more effort πŸ˜‚

Copy link
Member Author

Choose a reason for hiding this comment

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

sprint 😎

@MarcoGorelli MarcoGorelli merged commit 07de3f9 into narwhals-dev:main Nov 20, 2024
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants