Comments (5)
Yes, but to me the part that got me confused was
'3i'
does that mean 3 consecutive rows? or rows where the integers are within a window of 3
from polars.
Yeah, I recently asked if your final example should raise an exception:
from polars.
or rows where the integers are within a window of 3
This is it
So, if you have
In [13]: df
Out[13]:
shape: (5, 2)
┌───────┬───────┐
│ index ┆ value │
│ --- ┆ --- │
│ i64 ┆ i64 │
╞═══════╪═══════╡
│ 0 ┆ 1 │
│ 4 ┆ 4 │
│ 5 ┆ 2 │
│ 6 ┆ 4 │
│ 8 ┆ 1 │
└───────┴───────┘
Then the windows are:
- (-2, 0]
- (2, 4]
- (3, 5]
- (4, 6]
- (6, 8]
(where (
means "open interval" and ]
"closed interval")
In [14]: df.rolling('index', period='2i').agg(pl.col('index').alias('aggregated'))
Out[14]:
shape: (5, 2)
┌───────┬────────────┐
│ index ┆ aggregated │
│ --- ┆ --- │
│ i64 ┆ list[i64] │
╞═══════╪════════════╡
│ 0 ┆ [0] │
│ 4 ┆ [4] │
│ 5 ┆ [4, 5] │
│ 6 ┆ [5, 6] │
│ 8 ┆ [8] │
└───────┴────────────┘
from polars.
Which is great! But could be added to the documentation to make things clear to new users.
from polars.
yup - fancy making a PR?
from polars.
Related Issues (20)
- Add `show` method to `DataFrame` and `LazyFrame` HOT 1
- `gather` in `agg` context gathers values from other groups
- ShapeError: filter's length: 155 differs from that of the series: 0 HOT 9
- Version 0.20.30 bug HOT 4
- `.list.to_array()` fails if first element of a list column is excluded HOT 2
- `scan_parquet` + `with_row_index` causing `pl.len()` to return 0 HOT 1
- full join with coalesce=True panics if more key expressions are used than columns in a frame
- LazyFrames containing nested List types will cause panic in `collect()` HOT 1
- Another "coalesce=False" `join` schema issue HOT 2
- performance slowdown with `Expr.alias` HOT 3
- Shift(n) should accept a varying n HOT 4
- Rolling ewm/prod/rank HOT 4
- Improve string split API and DataTypes (`split`, `splitn`, `split_exact`) HOT 2
- Inconsistent Behavior with `inspect` in Aggregations
- In LazyFrame, select empty Series causes panic HOT 3
- `check_sorted` causes error in `DataFrame.rolling` HOT 3
- Expose API for custom grouping operations similar to expression plugin API
- add strategy="mode" for fill_null HOT 5
- `write_parquet(pyarrow=False)` with `Struct` panic: "The children must have an equal number of values." HOT 2
- Add `pl.Config.show_full` (or something similar) HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from polars.