pub struct Window { /* private fields */ }
Expand description
Primary utility struct for defining window in DataFrames
Implementations§
Source§impl Window
impl Window
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new empty WindowSpec
Sourcepub fn current_row() -> i64
pub fn current_row() -> i64
Returns 0
Sourcepub fn unbounded_following() -> i64
pub fn unbounded_following() -> i64
Returns i64::MAX
Sourcepub fn unbounded_preceding() -> i64
pub fn unbounded_preceding() -> i64
Returns i64::MIN
Sourcepub fn partition_by<I: ToVecExpr>(self, cols: I) -> WindowSpec
pub fn partition_by<I: ToVecExpr>(self, cols: I) -> WindowSpec
Creates a WindowSpec with the partitioning defined
Sourcepub fn order_by<I, T>(self, cols: I) -> WindowSpecwhere
T: ToExpr,
I: IntoIterator<Item = T>,
pub fn order_by<I, T>(self, cols: I) -> WindowSpecwhere
T: ToExpr,
I: IntoIterator<Item = T>,
Creates a WindowSpec with the ordering defined
Sourcepub fn range_between(self, start: i64, end: i64) -> WindowSpec
pub fn range_between(self, start: i64, end: i64) -> WindowSpec
Creates a WindowSpec with the frame boundaries defined, from start (inclusive) to end (inclusive).
Both start and end are relative from the current row. For example, “0” means “current row”, while “-1” means one off before the current row, and “5” means the five off after the current row.
Recommended to use [Window::unboundedPreceding], [Window::unboundedFollowing], and [Window::currentRow] to specify special boundary values, rather than using integral values directly.
§Example
let window = Window::new()
.partition_by(col("name"))
.order_by([col("age")])
.range_between(Window::unboundedPreceding(), Window::currentRow());
let df = df.with_column("rank", rank().over(window.clone()))
.with_column("min", min("age").over(window));
Sourcepub fn rows_between(self, start: i64, end: i64) -> WindowSpec
pub fn rows_between(self, start: i64, end: i64) -> WindowSpec
Creates a WindowSpec with the frame boundaries defined, from start (inclusive) to end (inclusive).
Both start and end are relative from the current row. For example, “0” means “current row”, while “-1” means one off before the current row, and “5” means the five off after the current row.
Recommended to use [Window::unboundedPreceding], [Window::unboundedFollowing], and [Window::currentRow] to specify special boundary values, rather than using integral values directly.
§Example
let window = Window::new()
.partition_by(col("name"))
.order_by([col("age")])
.rows_between(Window::unbounded_preceding(), Window::current_row());
let df = df.with_column("rank", rank().over(window.clone()))
.with_column("min", min("age").over(window));
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Window
impl RefUnwindSafe for Window
impl Send for Window
impl Sync for Window
impl Unpin for Window
impl UnwindSafe for Window
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request