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 dataframe.py #1411

Merged
merged 4 commits into from
Nov 20, 2024

Conversation

raisadz
Copy link
Contributor

@raisadz raisadz commented Nov 20, 2024

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

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

Related issues

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
@raisadz raisadz changed the title Docs dataframe native examples docs: use type hints + from_native/to_native in dataframe.py Nov 20, 2024
Copy link
Member

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

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

thanks @raisadz ! just one minor comment, then feel free to merge

(also, the lazy docstring needs copy-and-pasting into the stable v1 version)

>>> df = {"foo": [1, 2, 3], "bar": [6.5, 7.0, 8.5], "ham": ["a", "b", "c"]}
>>> df_pd = pd.DataFrame(df)
>>> df_pl = pl.DataFrame(df)
>>> df_pa = pa.table(df)

We define a library agnostic function:

>>> @nw.narwhalify
... def func(df):
>>> def agnostic_to_numpy(df_native: IntoDataFrame) -> np.array:
Copy link
Member

Choose a reason for hiding this comment

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

I think the return type should be np.ndarray (np.array is just the function to create arrays)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @MarcoGorelli! Addressed these.

@raisadz raisadz marked this pull request as ready for review November 20, 2024 11:35
@raisadz raisadz merged commit f77d137 into narwhals-dev:main Nov 20, 2024
23 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