• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home » Resolved: Failing to understand example in documentation about window functions (operations per group) in polars

Resolved: Failing to understand example in documentation about window functions (operations per group) in polars

0
By Isaac Tonny on 17/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

In the example under the section Operations per group the author writes:
But he doesn’t say what value or group he picked. The assumption is that in this example he selected as value the ‘speed’ column and groups over ‘Type 1’.
The resulting frame is :
He mentions that the colum ‘Type1’ isn’t contiguous, but he doesn’t explain why and i am failing to grasp the hints. 🙁
In the example he sorted ‘Speed'(My best guess), therefore speed should be continuous, but isn’t due to the last row with the value 95. On the other hand he just sorted the group ‘Type 1’, so how does the column get added back to the Dataframe?
For aggregations it’s clear because:

The results of the aggregation are projected back to the original rows. but what about operations within a group?


What am i missing? Is it just sorting the rows of each group? For example:
if i have Type 1 == ‘Water’ in row 1,3 and 7 it will just swap out these positions?

Answer:

What am i missing? Is it just sorting the rows of each group? For example:


if i have Type 1 == ‘Water’ in row 1,3 and 7 it will just swap out these positions?


Yes! 🙂
So the operations work within a group no matter at which row location the group elements are. The window functions will find them.

If you have better answer, please add a comment about this, thank you!

python-polars
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: Input Focus between two React Components

02/04/2023

Resolved: linq2db throws exception when filtering by nested collection

02/04/2023

Resolved: Table data is coming as empty in React

02/04/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.