-
Notifications
You must be signed in to change notification settings - Fork 176
feat: Add {Expr,Series}.cos
#3392
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
|
|
||
|
|
||
| @pytest.mark.skipif(PANDAS_VERSION < (2, 1, 0), reason="nullable types require pandas2+") | ||
| def test_cos_dtype_pandas_pyarrow() -> None: |
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.
wasn't actually certain if this test was necessary given the above one?
narwhals/expr.py
Outdated
| |values: double | | ||
| |cos: double | | ||
| |---- | | ||
| |values: [[0,1.5707963267948966,3.141592653589793]]| |
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.
open to suggestions on making this output a bit less off-putting!
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.
Maybe something like:
result = df.with_columns(cos=nw.col("values").cos()).select(nw.all().round(4))
FBruzzesi
left a comment
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.
Thanks @liamholmes31 ππΌ
Happy to merge once CI get green(er) π₯¦ (I think some of the values were copied-pasted from sine)
narwhals/expr.py
Outdated
| |values: double | | ||
| |cos: double | | ||
| |---- | | ||
| |values: [[0,1.5707963267948966,3.141592653589793]]| |
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.
Maybe something like:
result = df.with_columns(cos=nw.col("values").cos()).select(nw.all().round(4))
oops forgot to check the doctests, thanks fixed and tidied the rounding here! 81e0448 |
FBruzzesi
left a comment
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.
Thanks @liamholmes31

Description
Added cos methods for nw.Expr and nw.Series
What type of PR is this? (check all applicable)
Related issues
Checklist