Struct polars_lazy::prelude::Duration
source · pub struct Duration {
pub parsed_int: bool,
/* private fields */
}
rolling_window_by
only.Fields§
§parsed_int: bool
Implementations§
source§impl Duration
impl Duration
sourcepub fn parse(duration: &str) -> Duration
pub fn parse(duration: &str) -> Duration
Parse a string into a Duration
Strings are composed of a sequence of number-unit pairs, such as 5d
(5 days). A string may begin with a minus
sign, in which case it is interpreted as a negative duration. Some examples:
"1y"
: 1 year"-1w2d"
: negative 1 week, 2 days (i.e. -9 days)"3d12h4m25s"
: 3 days, 12 hours, 4 minutes, and 25 seconds
Aside from a leading minus sign, strings may not contain any characters other than numbers and letters (including whitespace).
The available units, in ascending order of magnitude, are as follows:
ns
: nanosecondus
: microsecondms
: milliseconds
: secondm
: minuteh
: hourd
: dayw
: weekmo
: calendar monthq
: calendar quartery
: calendar yeari
: index value (only for {Int32, Int64} dtypes)
By “calendar day”, we mean the corresponding time on the next day (which may not be 24 hours, depending on daylight savings). Similarly for “calendar week”, “calendar month”, “calendar quarter”, and “calendar year”.
§Panics
If the given str is invalid for any reason.
pub fn months_only(&self) -> bool
pub fn months(&self) -> i64
pub fn weeks_only(&self) -> bool
pub fn weeks(&self) -> i64
pub fn days_only(&self) -> bool
pub fn days(&self) -> i64
sourcepub fn is_full_days(&self) -> bool
pub fn is_full_days(&self) -> bool
Returns whether the duration consists of full days.
Note that 24 hours is not considered a full day due to possible daylight savings time transitions.
pub fn is_constant_duration(&self, time_zone: Option<&str>) -> bool
sourcepub fn nanoseconds(&self) -> i64
pub fn nanoseconds(&self) -> i64
Returns the nanoseconds from the Duration
without the weeks or months part.
pub fn truncate_impl<F, G, J>( &self, t: i64, tz: Option<&Tz>, nsecs_to_unit: F, timestamp_to_datetime: G, datetime_to_timestamp: J ) -> Result<i64, PolarsError>
pub fn truncate_ns(&self, t: i64, tz: Option<&Tz>) -> Result<i64, PolarsError>
pub fn truncate_us(&self, t: i64, tz: Option<&Tz>) -> Result<i64, PolarsError>
pub fn truncate_ms(&self, t: i64, tz: Option<&Tz>) -> Result<i64, PolarsError>
pub fn add_ns(&self, t: i64, tz: Option<&Tz>) -> Result<i64, PolarsError>
pub fn add_us(&self, t: i64, tz: Option<&Tz>) -> Result<i64, PolarsError>
pub fn add_ms(&self, t: i64, tz: Option<&Tz>) -> Result<i64, PolarsError>
Trait Implementations§
source§impl<'de> Deserialize<'de> for Duration
impl<'de> Deserialize<'de> for Duration
source§fn deserialize<__D>(
__deserializer: __D
) -> Result<Duration, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D
) -> Result<Duration, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
source§impl Ord for Duration
impl Ord for Duration
source§impl PartialEq for Duration
impl PartialEq for Duration
source§impl PartialOrd for Duration
impl PartialOrd for Duration
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl Serialize for Duration
impl Serialize for Duration
source§fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Copy for Duration
impl Eq for Duration
impl StructuralPartialEq for Duration
Auto Trait Implementations§
impl Freeze for Duration
impl RefUnwindSafe for Duration
impl Send for Duration
impl Sync for Duration
impl Unpin for Duration
impl UnwindSafe for Duration
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
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more