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

fix: Return appropriate data type for duration mean and median #14376

Merged
merged 1 commit into from
Feb 13, 2024

Conversation

mcrumiller
Copy link
Contributor

@mcrumiller mcrumiller commented Feb 8, 2024

Resolves #14375. Part of overall #13599.

This also moves one step closer to deprecating Series.dt.mean and Series.dt.median, as the base Series' mean and median now support duration dtypes.

Using the example from the issue, all cases now properly output a duration:

6 days, 0:00:00
2 days, 0:00:00
6 days, 0:00:00
2 days, 0:00:00
shape: (1, 2)
┌──────────────┬──────────────┐
│ mean         ┆ median       │
│ ---          ┆ ---          │
│ duration[μs] ┆ duration[μs] │
╞══════════════╪══════════════╡
│ 6d           ┆ 2d           │
└──────────────┴──────────────┘
shape: (1, 3)
┌─────┬──────────────┬──────────────┐
│ key ┆ mean         ┆ median       │
│ --- ┆ ---          ┆ ---          │
│ i64 ┆ duration[μs] ┆ duration[μs] │
╞═════╪══════════════╪══════════════╡
│ 1   ┆ 6d           ┆ 2d           │
└─────┴──────────────┴──────────────┘

@github-actions github-actions bot added fix Bug fix python Related to Python Polars rust Related to Rust Polars labels Feb 8, 2024
@mcrumiller mcrumiller marked this pull request as ready for review February 8, 2024 19:56
@ritchie46 ritchie46 merged commit 5667497 into pola-rs:main Feb 13, 2024
26 checks passed
@mcrumiller mcrumiller deleted the duration-mean-median branch February 13, 2024 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Bug fix python Related to Python Polars rust Related to Rust Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

mean and median for pl.Duration should return a duration
2 participants