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

depr(python): Deprecate dt.mean/dt.median in favor of mean/median #16888

Merged
merged 4 commits into from
Jun 12, 2024

Conversation

mcrumiller
Copy link
Contributor

@mcrumiller mcrumiller commented Jun 12, 2024

There is no good reason for these to be a namespace methods. The method on Series/Expr can determine the right result for the data type.

Changes

  • Deprecate Series methods dt.mean and dt.median. Users should use Series.mean or Series.median instead.

Example

Before

>>> from datetime import date
>>> s = pl.Series([date(2022, 1, 1), date(2022, 6, 1)])
>>> s.dt.mean()
datetime.datetime(2022, 3, 17, 12, 0)

After

>>> s.mean()
datetime.datetime(2022, 3, 17, 12, 0)

Copy link

codecov bot commented Jun 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.98%. Comparing base (47d19f3) to head (f0b4977).
Report is 12 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16888      +/-   ##
==========================================
- Coverage   81.41%   80.98%   -0.43%     
==========================================
  Files        1425     1437      +12     
  Lines      187964   189053    +1089     
  Branches     2704     2704              
==========================================
+ Hits       153022   153110      +88     
- Misses      34445    35446    +1001     
  Partials      497      497              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mcrumiller mcrumiller force-pushed the depr-date-mean branch 2 times, most recently from 2df4869 to e3596bf Compare June 12, 2024 01:18
Copy link
Member

@stinodego stinodego left a comment

Choose a reason for hiding this comment

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

Thanks, I left some small comments.

py-polars/polars/series/datetime.py Outdated Show resolved Hide resolved
@stinodego stinodego changed the title Deprecate dt.mean and dt.median depr(python): Deprecate dt.mean and dt.median Jun 12, 2024
@github-actions github-actions bot added deprecation Add a deprecation warning to outdated functionality python Related to Python Polars labels Jun 12, 2024
@stinodego stinodego changed the title depr(python): Deprecate dt.mean and dt.median depr(python): Deprecate dt.mean and dt.median in favor of mean and median Jun 12, 2024
@stinodego stinodego changed the title depr(python): Deprecate dt.mean and dt.median in favor of mean and median depr(python): Deprecate dt.mean/dt.median in favor of mean/median Jun 12, 2024
Copy link
Member

@stinodego stinodego left a comment

Choose a reason for hiding this comment

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

Thanks for this! Took a while with the reviews to get everything in, but happy we have this one done now 👍

@mcrumiller
Copy link
Contributor Author

Thanks for the help Stijn!

@stinodego stinodego merged commit b902601 into pola-rs:main Jun 12, 2024
14 checks passed
@mcrumiller mcrumiller deleted the depr-date-mean branch June 12, 2024 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deprecation Add a deprecation warning to outdated functionality python Related to Python Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants