polars_python/expr/
struct.rs1use pyo3::prelude::*;
2
3use crate::PyExpr;
4use crate::expr::ToExprs;
5
6#[pymethods]
7impl PyExpr {
8 fn struct_field_by_index(&self, index: i64) -> Self {
9 self.inner.clone().struct_().field_by_index(index).into()
10 }
11
12 fn struct_field_by_name(&self, name: &str) -> Self {
13 self.inner.clone().struct_().field_by_name(name).into()
14 }
15
16 fn struct_multiple_fields(&self, names: Vec<String>) -> Self {
17 self.inner.clone().struct_().field_by_names(&names).into()
18 }
19
20 fn struct_rename_fields(&self, names: Vec<String>) -> Self {
21 self.inner.clone().struct_().rename_fields(names).into()
22 }
23
24 #[cfg(feature = "json")]
25 fn struct_json_encode(&self) -> Self {
26 self.inner.clone().struct_().json_encode().into()
27 }
28
29 fn struct_with_fields(&self, fields: Vec<PyExpr>) -> Self {
30 let fields = fields.to_exprs();
31 let e = self.inner.clone().struct_().with_fields(fields);
32 e.into()
33 }
34}