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

rolling_*_by() functions work when by is integer while docs say it shouldn't #19491

Open
2 tasks done
etiennebacher opened this issue Oct 28, 2024 · 2 comments · May be fixed by #19715
Open
2 tasks done

rolling_*_by() functions work when by is integer while docs say it shouldn't #19491

etiennebacher opened this issue Oct 28, 2024 · 2 comments · May be fixed by #19715
Labels
documentation Improvements or additions to documentation 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

import polars as pl

df = pl.DataFrame({"a": [1, 2, 3, 4, 5, 6], "id": [11, 12, 13, 14, 15, 16]})

df.select(pl.col("a").rolling_mean_by("id", window_size = "2i"))

Log output

shape: (6, 1)
┌─────┐
│ a   │
│ --- │
│ f64 │
╞═════╡
│ 1.0 │
│ 1.5 │
│ 2.5 │
│ 3.5 │
│ 4.5 │
│ 5.5 │
└─────┘

Issue description

Mismatch between the docs of the by parameter, that say:

by: This column must be of dtype Datetime or Date.

and the code that works when by is integer.

Expected behavior

Not sure if this is just a documentation issue or if it should error when by is integer.

Installed versions

--------Version info---------
Polars:              1.12.0
Index type:          UInt32
Platform:            Linux-6.8.0-47-generic-x86_64-with-glibc2.39
Python:              3.12.3 (main, Sep 11 2024, 14:17:37) [GCC 13.2.0]
LTS CPU:             False

----Optional dependencies----
adbc_driver_manager  <not installed>
altair               <not installed>
cloudpickle          <not installed>
connectorx           <not installed>
deltalake            <not installed>
fastexcel            <not installed>
fsspec               <not installed>
gevent               <not installed>
great_tables         <not installed>
matplotlib           <not installed>
nest_asyncio         <not installed>
numpy                2.1.2
openpyxl             <not installed>
pandas               <not installed>
pyarrow              <not installed>
pydantic             <not installed>
pyiceberg            <not installed>
sqlalchemy           <not installed>
torch                <not installed>
xlsx2csv             <not installed>
xlsxwriter           <not installed>
@etiennebacher etiennebacher added bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars labels Oct 28, 2024
@cmdlineluser
Copy link
Contributor

It was recently added #19071 - so I think it's just a docs issue.

@MarcoGorelli
Copy link
Collaborator

thanks for the report - indeed, looks like I forgot to update the docs, thanks

@MarcoGorelli MarcoGorelli added documentation Improvements or additions to documentation and removed bug Something isn't working needs triage Awaiting prioritization by a maintainer labels Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation python Related to Python Polars
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants