pub struct Logical<K, T>(pub ChunkedArray<T>, _, pub Option<DataType>)
where
K: PolarsDataType,
T: PolarsDataType;
Expand description
Maps a logical type to a a chunked array implementation of the physical type. This saves a lot of compiler bloat and allows us to reuse functionality.
Tuple Fields
0: ChunkedArray<T>
2: Option<DataType>
Implementations
impl<K, T> Logical<K, T> where
K: PolarsDataType,
T: PolarsDataType,
Logical<K, T>: LogicalType,
impl<K, T> Logical<K, T> where
K: PolarsDataType,
T: PolarsDataType,
Logical<K, T>: LogicalType,
Extract month from underlying NaiveDate representation. Returns the year number in the calendar date.
Extract month from underlying NaiveDateTime representation. Returns the month number starting from 1.
The return value ranges from 1 to 12.
Extract weekday from underlying NaiveDate representation. Returns the weekday number where monday = 0 and sunday = 6
Returns the ISO week number starting from 1. The return value ranges from 1 to 53. (The last week of year differs by years.)
Extract day from underlying NaiveDate representation. Returns the day of month starting from 1.
The return value ranges from 1 to 31. (The last day of month differs by months.)
Returns the day of year starting from 1.
The return value ranges from 1 to 366. (The last day of year differs by years.)
Format Date with a fmt
rule. See chrono strftime/strptime.
Extract month from underlying NaiveDateTime representation. Returns the year number in the calendar date.
Extract month from underlying NaiveDateTime representation. Returns the month number starting from 1.
The return value ranges from 1 to 12.
Extract weekday from underlying NaiveDateTime representation. Returns the weekday number where monday = 0 and sunday = 6
Returns the ISO week number starting from 1. The return value ranges from 1 to 53. (The last week of year differs by years.)
Extract day from underlying NaiveDateTime representation. Returns the day of month starting from 1.
The return value ranges from 1 to 31. (The last day of month differs by months.)
Extract hour from underlying NaiveDateTime representation. Returns the hour number from 0 to 23.
Extract minute from underlying NaiveDateTime representation. Returns the minute number from 0 to 59.
Extract second from underlying NaiveDateTime representation. Returns the second number from 0 to 59.
Extract second from underlying NaiveDateTime representation. Returns the number of nanoseconds since the whole non-leap second. The range from 1,000,000,000 to 1,999,999,999 represents the leap second.
Returns the day of year starting from 1.
The return value ranges from 1 to 366. (The last day of year differs by years.)
Format Datetimewith a fmt
rule. See chrono strftime/strptime.
pub fn new_from_naive_datetime(
name: &str,
v: &[NaiveDateTime],
tu: TimeUnit
) -> Logical<DatetimeType, Int64Type>
pub fn parse_from_str_slice(
name: &str,
v: &[&str],
fmt: &str,
tu: TimeUnit
) -> Logical<DatetimeType, Int64Type>
pub fn new_from_duration(
name: &str,
v: &[Duration],
tu: TimeUnit
) -> Logical<DurationType, Int64Type>
Extract the hours from a Duration
Extract the days from a Duration
Extract the milliseconds from a Duration
Extract the nanoseconds from a Duration
Extract the seconds from a Duration
Format Date with a fmt
rule. See chrono strftime/strptime.
Extract hour from underlying NaiveDateTime representation. Returns the hour number from 0 to 23.
Extract minute from underlying NaiveDateTime representation. Returns the minute number from 0 to 59.
Extract second from underlying NaiveDateTime representation. Returns the second number from 0 to 59.
Extract second from underlying NaiveDateTime representation. Returns the number of nanoseconds since the whole non-leap second. The range from 1,000,000,000 to 1,999,999,999 represents the leap second.
pub fn truncate(
&self,
every: Duration,
offset: Duration
) -> Logical<DatetimeType, Int64Type>
Methods from Deref<Target = ChunkedArray<T>>
Convert all values to their absolute/positive value.
Append in place.
pub fn downcast_iter(
&self
) -> impl Iterator<Item = &PrimitiveArray<<T as PolarsNumericType>::Native>> + DoubleEndedIterator
pub fn downcast_chunks(
&self
) -> Chunks<'_, PrimitiveArray<<T as PolarsNumericType>::Native>>
Apply a rolling mean (moving mean) over the values in this array.
A window of length window_size
will traverse the array. The values that fill this window
will (optionally) be multiplied with the weights given by the weights
vector. The resulting
values will be aggregated to their mean.
Apply a rolling sum (moving sum) over the values in this array.
A window of length window_size
will traverse the array. The values that fill this window
will (optionally) be multiplied with the weights given by the weights
vector. The resulting
values will be aggregated to their sum.
Apply a rolling median (moving median) over the values in this array.
A window of length window_size
will traverse the array. The values that fill this window
will (optionally) be weighted according to the weights
vector.
pub fn rolling_quantile(
&self,
quantile: f64,
interpolation: QuantileInterpolOptions,
options: RollingOptions
) -> Result<Series, PolarsError>
pub fn rolling_quantile(
&self,
quantile: f64,
interpolation: QuantileInterpolOptions,
options: RollingOptions
) -> Result<Series, PolarsError>
Apply a rolling quantile (moving quantile) over the values in this array.
A window of length window_size
will traverse the array. The values that fill this window
will (optionally) be weighted according to the weights
vector.
Apply a rolling min (moving min) over the values in this array.
A window of length window_size
will traverse the array. The values that fill this window
will (optionally) be multiplied with the weights given by the weights
vector. The resulting
values will be aggregated to their min.
Apply a rolling max (moving max) over the values in this array.
A window of length window_size
will traverse the array. The values that fill this window
will (optionally) be multiplied with the weights given by the weights
vector. The resulting
values will be aggregated to their max.
pub fn rolling_apply_float<F>(
&self,
window_size: usize,
f: F
) -> Result<ChunkedArray<T>, PolarsError> where
F: Fn(&ChunkedArray<T>) -> Option<<T as PolarsNumericType>::Native>,
pub fn rolling_apply_float<F>(
&self,
window_size: usize,
f: F
) -> Result<ChunkedArray<T>, PolarsError> where
F: Fn(&ChunkedArray<T>) -> Option<<T as PolarsNumericType>::Native>,
Apply a rolling custom function. This is pretty slow because of dynamic dispatch.
Apply a rolling var (moving var) over the values in this array.
A window of length window_size
will traverse the array. The values that fill this window
will (optionally) be multiplied with the weights given by the weights
vector. The resulting
values will be aggregated to their var.
Apply a rolling std (moving std) over the values in this array.
A window of length window_size
will traverse the array. The values that fill this window
will (optionally) be multiplied with the weights given by the weights
vector. The resulting
values will be aggregated to their std.
Convert missing values to NaN
values.
pub fn into_no_null_iter(
&self
) -> impl Iterator<Item = bool> + Send + Sync + ExactSizeIterator + DoubleEndedIterator + TrustedLen
pub fn into_no_null_iter(
&'a self
) -> impl Iterator<Item = &'a str> + Send + Sync + ExactSizeIterator + DoubleEndedIterator + TrustedLen + 'a
pub fn into_no_null_iter(
&self
) -> impl Iterator<Item = Series> + Send + Sync + ExactSizeIterator + DoubleEndedIterator + TrustedLen
pub fn into_no_null_iter(
&self
) -> impl Iterator<Item = &T> + Send + Sync + ExactSizeIterator + DoubleEndedIterator + TrustedLen
pub fn into_no_null_iter(
&self
) -> impl Iterator<Item = u32> + Send + Sync + ExactSizeIterator + DoubleEndedIterator + TrustedLen
pub fn to_ndarray(
&self
) -> Result<ArrayBase<ViewRepr<&<T as PolarsNumericType>::Native>, Dim<[usize; 1]>>, PolarsError>
pub fn to_ndarray(
&self
) -> Result<ArrayBase<ViewRepr<&<T as PolarsNumericType>::Native>, Dim<[usize; 1]>>, PolarsError>
If data is aligned in a single chunk and has no Null values a zero copy view is returned
as an ndarray
pub fn to_ndarray<N>(
&self
) -> Result<ArrayBase<OwnedRepr<<N as PolarsNumericType>::Native>, Dim<[usize; 2]>>, PolarsError> where
N: PolarsNumericType,
pub fn to_ndarray<N>(
&self
) -> Result<ArrayBase<OwnedRepr<<N as PolarsNumericType>::Native>, Dim<[usize; 2]>>, PolarsError> where
N: PolarsNumericType,
If all nested Series
have the same length, a 2 dimensional ndarray::Array
is returned.
Get a reference to the mapping of categorical types to the string values.
This is an iterator over a ListChunked that save allocations.
A Series is:
1. Arc
The ArrayRef we indicated with 3. will be updated during iteration. The Series will be pinned in memory, saving an allocation for
- Arc<..>
- Vec<…>
Warning
Though memory safe in the sense that it will not read unowned memory, UB, or memory leaks
this function still needs precautions. The returned should never be cloned or taken longer
than a single iteration, as every call on next
of the iterator will change the contents of
that Series.
pub fn apply_amortized<'a, F>(&'a self, f: F) -> ChunkedArray<ListType> where
F: FnMut(UnstableSeries<'a>) -> Series,
pub fn apply_amortized<'a, F>(&'a self, f: F) -> ChunkedArray<ListType> where
F: FnMut(UnstableSeries<'a>) -> Series,
Apply a closure F
elementwise.
pub fn try_apply_amortized<'a, F>(
&'a self,
f: F
) -> Result<ChunkedArray<ListType>, PolarsError> where
F: FnMut(UnstableSeries<'a>) -> Result<Series, PolarsError>,
Get the value by index in the sublists.
So index 0
would return the first item of every sublist
and index -1
would return the last item of every sublist
if an index is out of bounds, it will return a None
.
pub unsafe fn get_object_unchecked(
&self,
index: usize
) -> Option<&(dyn PolarsObjectSafe + 'static)>
pub unsafe fn get_object_unchecked(
&self,
index: usize
) -> Option<&(dyn PolarsObjectSafe + 'static)>
Get a hold to an object that can be formatted or downcasted via the Any trait.
Safety
No bounds checks
Get a hold to an object that can be formatted or downcasted via the Any trait.
pub fn sample_n(
&self,
n: usize,
with_replacement: bool,
seed: u64
) -> Result<ChunkedArray<T>, PolarsError>
pub fn sample_n(
&self,
n: usize,
with_replacement: bool,
seed: u64
) -> Result<ChunkedArray<T>, PolarsError>
Sample n datapoints from this ChunkedArray.
pub fn sample_frac(
&self,
frac: f64,
with_replacement: bool,
seed: u64
) -> Result<ChunkedArray<T>, PolarsError>
pub fn sample_frac(
&self,
frac: f64,
with_replacement: bool,
seed: u64
) -> Result<ChunkedArray<T>, PolarsError>
Sample a fraction between 0.0-1.0 of this ChunkedArray.
pub fn json_path_match(
&self,
json_path: &str
) -> Result<ChunkedArray<Utf8Type>, PolarsError>
pub fn json_path_match(
&self,
json_path: &str
) -> Result<ChunkedArray<Utf8Type>, PolarsError>
Extract json path, first match Refer to https://goessner.net/articles/JsonPath/
pub fn hex_decode(
&self,
strict: Option<bool>
) -> Result<ChunkedArray<Utf8Type>, PolarsError>
pub fn base64_decode(
&self,
strict: Option<bool>
) -> Result<ChunkedArray<Utf8Type>, PolarsError>
Get the length of the string values.
Check if strings contain a regex pattern
Replace the leftmost (sub)string by a regex pattern
pub fn replace_all(
&self,
pat: &str,
val: &str
) -> Result<ChunkedArray<Utf8Type>, PolarsError>
pub fn replace_all(
&self,
pat: &str,
val: &str
) -> Result<ChunkedArray<Utf8Type>, PolarsError>
Replace all (sub)strings by a regex pattern
pub fn extract(
&self,
pat: &str,
group_index: usize
) -> Result<ChunkedArray<Utf8Type>, PolarsError>
pub fn extract(
&self,
pat: &str,
group_index: usize
) -> Result<ChunkedArray<Utf8Type>, PolarsError>
Extract the nth capture group from pattern
Modify the strings to their lowercase equivalent
Modify the strings to their uppercase equivalent
Concat with the values from a second Utf8Chunked
pub fn str_slice(
&self,
start: i64,
length: Option<u64>
) -> Result<ChunkedArray<Utf8Type>, PolarsError>
pub fn str_slice(
&self,
start: i64,
length: Option<u64>
) -> Result<ChunkedArray<Utf8Type>, PolarsError>
Slice the string values
Determines a substring starting from start
and with optional length length
of each of the elements in array
.
start
can be negative, in which case the start counts from the end of the string.
pub fn as_date_not_exact(
&self,
fmt: Option<&str>
) -> Result<Logical<DateType, Int32Type>, PolarsError>
pub fn as_datetime_not_exact(
&self,
fmt: Option<&str>,
tu: TimeUnit
) -> Result<Logical<DatetimeType, Int64Type>, PolarsError>
pub fn as_datetime(
&self,
fmt: Option<&str>,
tu: TimeUnit
) -> Result<Logical<DatetimeType, Int64Type>, PolarsError>
Get the index of the first non null value in this ChunkedArray.
Get the buffer of bits representing null values
Return if any the chunks in this [ChunkedArray]
have a validity bitmap.
no bitmap means no null values.
Shrink the capacity of this array to fit it’s length.
pub fn unpack_series_matching_type(
&self,
series: &Series
) -> Result<&ChunkedArray<T>, PolarsError>
pub fn unpack_series_matching_type(
&self,
series: &Series
) -> Result<&ChunkedArray<T>, PolarsError>
Series to ChunkedArray
Unique id representing the number of chunks
A reference to the chunks
Returns true if contains a single chunk and has no null values
Count the null values.
Append arrow array in place.
let mut array = Int32Chunked::new("array", &[1, 2]);
let array_2 = Int32Chunked::new("2nd", &[3]);
array.append(&array_2);
assert_eq!(Vec::from(&array), [Some(1), Some(2), Some(3)])
Get a mask of the null values.
Get a mask of the valid values.
Contiguous slice
pub fn data_views(
&self
) -> impl Iterator<Item = &[<T as PolarsNumericType>::Native]> + DoubleEndedIterator
pub fn data_views(
&self
) -> impl Iterator<Item = &[<T as PolarsNumericType>::Native]> + DoubleEndedIterator
Get slices of the underlying arrow data. NOTE: null values should be taken into account by the user of these slices as they are handled separately
pub fn into_no_null_iter(
&self
) -> impl Iterator<Item = <T as PolarsNumericType>::Native> + Send + Sync + ExactSizeIterator + DoubleEndedIterator + TrustedLen
Get the inner data type of the list.
Apply lhs - self
Apply lhs / self
Apply lhs % self
Trait Implementations
Auto Trait Implementations
impl<K, T> !RefUnwindSafe for Logical<K, T>
impl<K, T> !UnwindSafe for Logical<K, T>
Blanket Implementations
Mutably borrows from an owned value. Read more