[−][src]Struct polars_lazy::frame::LazyFrame
Lazy abstraction over an eager DataFrame
.
It really is an abstraction over a logical plan. The methods of this struct will incrementally
modify a logical plan until output is requested (via collect)
Implementations
impl LazyFrame
[src]
pub fn to_dot(&self, optimized: bool) -> Result<String>
[src]
Get a dot language representation of the LogicalPlan.
pub fn with_projection_pushdown(mut self: Self, toggle: bool) -> Self
[src]
Toggle projection pushdown optimization.
pub fn with_predicate_pushdown(mut self: Self, toggle: bool) -> Self
[src]
Toggle predicate pushdown optimization.
pub fn with_type_coercion(mut self: Self, toggle: bool) -> Self
[src]
Toggle type coercion optimization.
pub fn with_simplify_expr(mut self: Self, toggle: bool) -> Self
[src]
Toggle expression simplification optimization on or off
pub fn with_aggregate_pushdown(mut self: Self, toggle: bool) -> Self
[src]
Toggle aggregate pushdown.
pub fn with_string_cache(mut self: Self, toggle: bool) -> Self
[src]
Toggle global string cache.
pub fn describe_plan(&self) -> String
[src]
Describe the logical plan.
pub fn describe_optimized_plan(&self) -> Result<String>
[src]
Describe the optimized logical plan.
pub fn sort(self, by_column: &str, reverse: bool) -> Self
[src]
Add a sort operation to the logical plan.
Example
use polars_core::prelude::*; use polars_lazy::prelude::*; /// Sort DataFrame by 'sepal.width' column fn example(df: DataFrame) -> LazyFrame { df.lazy() .sort("sepal.width", false) }
pub fn reverse(self) -> Self
[src]
Reverse the DataFrame
Example
use polars_core::prelude::*; use polars_lazy::prelude::*; fn example(df: DataFrame) -> LazyFrame { df.lazy() .reverse() }
pub fn with_column_renamed(self, existing_name: &str, new_name: &str) -> Self
[src]
Rename a column in the DataFrame
pub fn shift(self, periods: i32) -> Self
[src]
Shift the values by a given period and fill the parts that will be empty due to this operation
with Nones
.
See the method on Series for more info on the shift
operation.
pub fn fill_none(self, fill_value: Expr) -> LazyFrame
[src]
Fill none values in the DataFrame
pub fn cache(self) -> Self
[src]
Caches the result into a new LazyFrame. This should be used to prevent computations running multiple times
pub fn fetch(self, n_rows: usize) -> Result<DataFrame>
[src]
Fetch is like a collect operation, but it overwrites the number of rows read by every scan operation. This is a utility that helps debug a query on a smaller number of rows.
Note that the fetch does not guarantee the final number of rows in the DataFrame. Filter, join operations and a lower number of rows available in the scanned file influence the final number of rows.
pub fn collect(self) -> Result<DataFrame>
[src]
Execute all the lazy operations and collect them into a DataFrame. Before execution the query is being optimized.
Example
use polars_core::prelude::*; use polars_lazy::prelude::*; fn example(df: DataFrame) -> Result<DataFrame> { df.lazy() .groupby(vec![col("foo")]) .agg(vec!(col("bar").sum(), col("ham").mean().alias("avg_ham"))) .collect() }
pub fn filter(self, predicate: Expr) -> Self
[src]
Filter by some predicate expression.
Example
use polars_core::prelude::*; use polars_lazy::prelude::*; fn example(df: DataFrame) -> LazyFrame { df.lazy() .filter(col("sepal.width").is_not_null()) .select(&[col("sepal.width"), col("sepal.length")]) }
pub fn select<E: AsRef<[Expr]>>(self, exprs: E) -> Self
[src]
Select (and rename) columns from the query.
Columns can be selected with col;
If you want to select all columns use col("*")
.
Example
use polars_core::prelude::*; use polars_lazy::prelude::*; fn example(df: DataFrame) -> LazyFrame { df.lazy() .select(&[col("foo"), col("bar").alias("ham")]) }
pub fn groupby(self, by: Vec<Expr>) -> LazyGroupBy
[src]
Group by and aggregate.
Example
use polars_core::prelude::*; use polars_lazy::prelude::*; fn example(df: DataFrame) -> LazyFrame { df.lazy() .groupby(vec![col("date")]) .agg(vec![ col("rain").min(), col("rain").sum(), col("rain").quantile(0.5).alias("median_rain"), ]) .sort("date", false) }
pub fn left_join(
self,
other: LazyFrame,
left_on: Expr,
right_on: Expr,
options: Option<JoinOptions>
) -> LazyFrame
[src]
self,
other: LazyFrame,
left_on: Expr,
right_on: Expr,
options: Option<JoinOptions>
) -> LazyFrame
Join query with other lazy query.
Example
use polars_core::prelude::*; use polars_lazy::prelude::*; fn join_dataframes(ldf: LazyFrame, other: LazyFrame) -> LazyFrame { ldf .left_join(other, col("foo"), col("bar"), None) }
pub fn outer_join(
self,
other: LazyFrame,
left_on: Expr,
right_on: Expr,
options: Option<JoinOptions>
) -> LazyFrame
[src]
self,
other: LazyFrame,
left_on: Expr,
right_on: Expr,
options: Option<JoinOptions>
) -> LazyFrame
Join query with other lazy query.
Example
use polars_core::prelude::*; use polars_lazy::prelude::*; fn join_dataframes(ldf: LazyFrame, other: LazyFrame) -> LazyFrame { ldf .outer_join(other, col("foo"), col("bar"), None) }
pub fn inner_join(
self,
other: LazyFrame,
left_on: Expr,
right_on: Expr,
options: Option<JoinOptions>
) -> LazyFrame
[src]
self,
other: LazyFrame,
left_on: Expr,
right_on: Expr,
options: Option<JoinOptions>
) -> LazyFrame
Join query with other lazy query.
Example
use polars_core::prelude::*; use polars_lazy::prelude::*; fn join_dataframes(ldf: LazyFrame, other: LazyFrame) -> LazyFrame { ldf .inner_join(other, col("foo"), col("bar").cast(DataType::Utf8), None) }
pub fn join(
self,
other: LazyFrame,
left_on: Vec<Expr>,
right_on: Vec<Expr>,
options: Option<JoinOptions>,
how: JoinType
) -> LazyFrame
[src]
self,
other: LazyFrame,
left_on: Vec<Expr>,
right_on: Vec<Expr>,
options: Option<JoinOptions>,
how: JoinType
) -> LazyFrame
Generic join function that can join on multiple columns.
pub fn with_column(self, expr: Expr) -> LazyFrame
[src]
Add a column to a DataFrame
Example
use polars_core::prelude::*; use polars_lazy::prelude::*; fn add_column(df: DataFrame) -> LazyFrame { df.lazy() .with_column( when(col("sepal.length").lt(lit(5.0))) .then(lit(10)) .otherwise(lit(1)) .alias("new_column_name"), ) }
pub fn with_columns(self, exprs: Vec<Expr>) -> LazyFrame
[src]
Add multiple columns to a DataFrame.
Example
use polars_core::prelude::*; use polars_lazy::prelude::*; fn add_columns(df: DataFrame) -> LazyFrame { df.lazy() .with_columns( vec![lit(10).alias("foo"), lit(100).alias("bar")] ) }
pub fn max(self) -> LazyFrame
[src]
Aggregate all the columns as their maximum values.
pub fn min(self) -> LazyFrame
[src]
Aggregate all the columns as their minimum values.
pub fn sum(self) -> LazyFrame
[src]
Aggregate all the columns as their sum values.
pub fn mean(self) -> LazyFrame
[src]
Aggregate all the columns as their mean values.
pub fn median(self) -> LazyFrame
[src]
Aggregate all the columns as their median values.
pub fn quantile(self, quantile: f64) -> LazyFrame
[src]
Aggregate all the columns as their quantile values.
pub fn std(self) -> LazyFrame
[src]
Aggregate all the columns as their standard deviation values.
pub fn var(self) -> LazyFrame
[src]
Aggregate all the columns as their variance values.
pub fn explode(self, columns: Vec<String>) -> LazyFrame
[src]
Apply explode operation. See eager explode.
pub fn drop_duplicates(
self,
maintain_order: bool,
subset: Option<Vec<String>>
) -> LazyFrame
[src]
self,
maintain_order: bool,
subset: Option<Vec<String>>
) -> LazyFrame
Drop duplicate rows. See eager.
pub fn drop_nulls(self, subset: Option<&[String]>) -> LazyFrame
[src]
Drop null rows.
Equal to LazyFrame::filter(col("*").is_not_null())
pub fn slice(self, offset: usize, len: usize) -> LazyFrame
[src]
Slice the DataFrame.
pub fn melt(self, id_vars: Vec<String>, value_vars: Vec<String>) -> LazyFrame
[src]
Melt the DataFrame from wide to long format
pub fn limit(self, n: usize) -> LazyFrame
[src]
Limit the DataFrame to the first n
rows. Note if you don't want the rows to be scanned,
use fetch.
pub fn map<F>(
self,
function: F,
optimizations: Option<AllowedOptimizations>,
schema: Option<Schema>
) -> LazyFrame where
F: DataFrameUdf + 'static,
[src]
self,
function: F,
optimizations: Option<AllowedOptimizations>,
schema: Option<Schema>
) -> LazyFrame where
F: DataFrameUdf + 'static,
Apply a function/closure once the logical plan get executed.
Warning
This can blow up in your face if the schema is changed due to the operation. The optimizer relies on a correct schema.
You can toggle certain optimizations off.
Trait Implementations
impl Clone for LazyFrame
[src]
impl Default for LazyFrame
[src]
impl From<LogicalPlan> for LazyFrame
[src]
fn from(plan: LogicalPlan) -> Self
[src]
Auto Trait Implementations
impl !RefUnwindSafe for LazyFrame
[src]
impl Send for LazyFrame
[src]
impl Sync for LazyFrame
[src]
impl Unpin for LazyFrame
[src]
impl !UnwindSafe for LazyFrame
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> Cast<U> for T where
U: FromCast<T>,
U: FromCast<T>,
pub fn cast(self) -> U
impl<T> From<T> for T
[src]
impl<T> FromCast<T> for T
pub fn from_cast(t: T) -> T
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Pointable for T
pub const ALIGN: usize
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
pub unsafe fn drop(ptr: usize)
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,