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

Median doesn't have same precision as min/max in datetime #20811

Open
2 tasks done
etiennebacher opened this issue Jan 20, 2025 · 0 comments
Open
2 tasks done

Median doesn't have same precision as min/max in datetime #20811

etiennebacher opened this issue Jan 20, 2025 · 0 comments
Labels
A-temporal Area: date/time functionality bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars

Comments

@etiennebacher
Copy link
Contributor

Checks

  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest version of Polars.

Reproducible example

from datetime import datetime
import polars as pl

dat = pl.DataFrame(data={"datetime": [datetime.max]})

dat.select(
    min=pl.col("datetime").min(), 
    max=pl.col("datetime").max(),
    median=pl.col("datetime").median()
)

Log output

shape: (1, 3)
┌─────────────────┬─────────────────┬───────────────────────┐
│ min             ┆ max             ┆ median                │
│ ---             ┆ ---             ┆ ---                   │
│ datetime[μs]    ┆ datetime[μs]    ┆ datetime[μs]          │
╞═════════════════╪═════════════════╪═══════════════════════╡
│ 9999-12-31      ┆ 9999-12-31      ┆ +10000-01-01 00:00:00 │
│ 23:59:59.999999 ┆ 23:59:59.999999 ┆                       │
└─────────────────┴─────────────────┴───────────────────────┘

Issue description

Median is different from the others while it should be equal. This is also a bit related to:

Expected behavior

Min, median and max should all have the same value in this case.

Installed versions

--------Version info---------
Polars:              1.20.0
Index type:          UInt32
Platform:            Linux-6.8.0-50-generic-x86_64-with-glibc2.39
Python:              3.12.3 (main, Nov  6 2024, 18:32:19) [GCC 13.2.0]
LTS CPU:             False

----Optional dependencies----
Azure CLI            <not installed>
adbc_driver_manager  1.3.0
altair               5.5.0
azure.identity       <not installed>
boto3                1.35.88
cloudpickle          3.1.0
connectorx           0.4.0
deltalake            0.22.3
fastexcel            0.12.0
fsspec               2024.12.0
gevent               24.11.1
google.auth          2.37.0
great_tables         0.15.0
matplotlib           3.10.0
numpy                2.0.2
openpyxl             3.1.5
pandas               2.2.3
pyarrow              18.1.0
pydantic             2.10.4
pyiceberg            <not installed>
sqlalchemy           2.0.36
torch                <not installed>
xlsx2csv             0.8.4
xlsxwriter           3.2.0
@etiennebacher etiennebacher added bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars labels Jan 20, 2025
@nameexhaustion nameexhaustion added the A-temporal Area: date/time functionality label Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-temporal Area: date/time functionality bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars
Projects
None yet
Development

No branches or pull requests

2 participants