We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
mean
median
pl.Time
Part of #13599. mean and median either do not work, return null, or do not return the proper dtype, except in a groupby context.
from datetime import time import polars as pl s = pl.Series([time(hour=1), time(hour=2), time(hour=15)]) df = pl.DataFrame({ "key": [1, 1, 1], "s": s }) ### Series print(s.mean()) print(s.median()) print(s.dt.mean()) # errors print(s.dt.median()) # errors
21600000000000.0 21600000000000.0 AttributeError: type object 'Time' has no attribute 'time_unit'
print( df.select( col("s").mean().alias("mean"), # col("s").median().alias("median") ## errors ) )
shape: (1, 1) ┌──────┐ │ mean │ │ --- │ │ time │ ╞══════╡ │ null │ └──────┘
print( df.group_by("key").agg( col("s").mean().alias("mean"), col("s").median().alias("median") ) )
shape: (1, 3) ┌─────┬──────────┬──────────┐ │ key ┆ mean ┆ median │ │ --- ┆ --- ┆ --- │ │ i64 ┆ time ┆ time │ ╞═════╪══════════╪══════════╡ │ 1 ┆ 06:00:00 ┆ 02:00:00 │ └─────┴──────────┴──────────┘
--------Version info--------- Polars: 0.20.7 Index type: UInt32 Platform: Linux-5.15.133.1-microsoft-standard-WSL2-x86_64-with-glibc2.35 Python: 3.12.1 (main, Jan 31 2024, 09:51:46) [GCC 11.4.0] ----Optional dependencies---- adbc_driver_manager: 0.9.0 cloudpickle: 3.0.0 connectorx: <not installed> deltalake: 0.15.2 fsspec: 2023.12.2 gevent: 23.9.1 hvplot: 0.9.2 matplotlib: 3.8.2 numpy: 1.26.4 openpyxl: 3.1.2 pandas: 2.2.0 pyarrow: 15.0.0 pydantic: 2.6.1 pyiceberg: 0.5.1 pyxlsb: 1.0.10 sqlalchemy: 2.0.25 xlsx2csv: 0.8.1 xlsxwriter: 3.1.9
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
Checks
Issue Description
Part of #13599.
mean
andmedian
either do not work, return null, or do not return the proper dtype, except in a groupby context.Frame
GroupBy
Installed versions
The text was updated successfully, but these errors were encountered: