Skip to content

Expr.Dt (DtOps) ​

Namespace: Polars.FSharp

Instance Methods ​

AddBusinessDays ​

Add business days to a date column.

Overload: Add business days using an integer literal.

fsharp
member AddBusinessDays(
    n: Expr,
    ?weekMask: bool[],
    ?holidays: seq<DateOnly>,
    ?roll: Roll
) : Expr

member AddBusinessDays(
    n: int,
    ?weekMask: bool[],
    ?holidays: seq<DateOnly>,
    ?roll: Roll
) : Expr

Parameters

NameTypeDescription
nExpr / intNumber of business days to add.
weekMaskbool[] (optional)Array of 7 bools (Mon-Sun) indicating business days. Default: [true, true, true, true, true, false, false].
holidaysseq<DateOnly> (optional)List of holidays to skip.
rollRoll (optional)Strategy for handling non-business start dates. Default: Raise.

BaseUtcOffset ​

Base offset from UTC. This is usually constant for all datetimes in a given time zone, but may vary in the rare case that a country switches time zone, like Samoa (Apia) did at the end of 2011.

fsharp
member BaseUtcOffset : unit -> Expr

Returns: Expression/Series of data type Duration.


Century ​

Extract the century from underlying representation.Returns the century number in the calendar date.

fsharp
member Century : unit -> Expr

Returns: Expression/Series of data type Int32.


Combine ​

Combine the date from the underlying date/datetime with the time from another expression.

The resulting Series will have the specified TimeUnit.

fsharp
member Combine(time: Expr, ?timeUnit: TimeUnit) : Expr

Parameters

NameTypeDescription
timeExprAn expression yielding the Time component.
timeUnitTimeUnit (optional)The desired TimeUnit for the resulting Datetime.
Note: Only sub-second units (TimeUnit.Nanoseconds, TimeUnit.Microseconds, TimeUnit.Milliseconds) are supported.

ConvertTimeZone ​

Convert the datetime to a different time zone. The underlying physical value (UTC timestamp) remains the same, but the display time changes.

fsharp
member ConvertTimeZone(timeZone: string) : Expr

Parameters

NameTypeDescription
timeZonestring-

Date ​

Cast to Date (remove time component).

fsharp
member Date : unit -> Expr

Day ​

Get the day from the underlying date/datetime.

fsharp
member Day : unit -> Expr

DayInMonth ​

Extract the number of days in the month from the underlying Date representation.Returns the number of days in the month. The return value ranges from 28 to 31.

fsharp
member DayInMonth : unit -> Expr

Returns: Expression/Series of data type Int8.


DstOffset ​

Additional offset currently in effect (typically due to daylight saving time).

fsharp
member DstOffset : unit -> Expr

Returns: Expression/Series of data type Duration.


Epoch ​

Get the time passed since the Unix epoch (1970-01-01 00:00:00).

fsharp
member Epoch(?timeUnit: EpochTimeUnit) : Expr

Parameters

NameTypeDescription
timeUnitEpochTimeUnit (optional)The time unit to compute the epoch for. Supported units: Nanoseconds, Microseconds, Milliseconds, Second, Day. (default: Microseconds)

Returns: A new expression/Series representing the epoch time.


Hour ​

Get the hour from the underlying datetime.

fsharp
member Hour : unit -> Expr

IsBusinessDay ​

Check if the date is a business day.

fsharp
member IsBusinessDay(?weekMask: bool[], ?holidays: seq<DateOnly>) : Expr

Parameters

NameTypeDescription
weekMaskbool[] (optional)Array of 7 bools (Mon-Sun). Default: Mon-Fri are business days.
holidaysseq<DateOnly> (optional)List of holidays.

IsLeapYear ​

Determine whether the year of the underlying date is a leap year.

fsharp
member IsLeapYear : unit -> Expr

Returns: Expression/Series of data type Boolean.


IsoYear ​

Get the ISO year from the underlying date/datetime.

fsharp
member IsoYear : unit -> Expr

Microsecond ​

Get the microsecond from the underlying datetime.

fsharp
member Microsecond : unit -> Expr

Millennium ​

Extract the millennium from underlying representation. Applies to Date and Datetime columns. Returns the millennium number in the calendar date.

fsharp
member Millennium : unit -> Expr

Returns: Expression/Series of data type Int32.


Millisecond ​

Get the millisecond from the underlying datetime.

fsharp
member Millisecond : unit -> Expr

Minute ​

Get the minute from the underlying datetime.

fsharp
member Minute : unit -> Expr

Month ​

Get the month from the underlying date/datetime.

fsharp
member Month : unit -> Expr

MonthEnd ​

Roll forward to the last day of the month. For datetimes, the time-of-day is preserved.

fsharp
member MonthEnd : unit -> Expr

Returns: Expression/Series of data type Date or Datetime.


MonthStart ​

Roll backward to the first day of the month. For datetimes, the time-of-day is preserved.

fsharp
member MonthStart : unit -> Expr

Returns: Expression/Series of data type Date or Datetime.


Nanosecond ​

Get the nanosecond from the underlying datetime.

fsharp
member Nanosecond : unit -> Expr

OffsetBy ​

Offset the date by a given duration string (e.g., "1d", "-2h").

fsharp
member OffsetBy(duration: Dur) : Expr

Parameters

NameTypeDescription
durationDur-

OrdinalDay ​

Get the ordinal day(day of year) from the underlying date/datetime.

fsharp
member OrdinalDay : unit -> Expr

Quarter ​

Get the quarter from the underlying date/datetime.

fsharp
member Quarter : unit -> Expr

Replace ​

Replace the datetime components of the underlying Datetime/Date.

fsharp
member Replace(
    ?year: int,
    ?month: int,
    ?day: int,
    ?hour: int,
    ?minute: int,
    ?second: int,
    ?microsecond: int,
    ?ambiguous: Expr
) : Expr

Parameters

NameTypeDescription
yearint (optional)Year to replace
monthint (optional)Month to replace
dayint (optional)Day to replace
hourint (optional)Hour to replace
minuteint (optional)Minute to replace
secondint (optional)Second to replace
microsecondint (optional)Microsecond to replace
ambiguousExpr (optional)Determine how to deal with ambiguous datetimes.

Returns: A new expression.


ReplaceTimeZone ​

Replace the time zone of a datetime. Use None (null) to make it TimeZone-Naive. ambiguous: Strategy for DST overlaps ("raise", "earliest", "latest", "null"). nonExistent: Strategy for missing DST times ("raise", "null").

Helper: Replace time zone with a specific string.

fsharp
member ReplaceTimeZone(timeZone: string option, ?ambiguous: Expr, ?nonExistent: NonExistent) : Expr
member ReplaceTimeZone(timeZone: string, ?ambiguous: Expr, ?nonExistent: NonExistent) : Expr

Parameters

NameTypeDescription
timeZonestring option-
ambiguousExpr (optional)-
nonExistentNonExistent (optional)-

Round ​

Round dates to the nearest interval.

fsharp
member Round(every: Dur) : Expr

Parameters

NameTypeDescription
everyDur-

Second ​

Get the second from the underlying datetime.

fsharp
member Second(?fractional: bool) : Expr

Parameters

NameTypeDescription
fractionalbool (optional)Whether to include the fractional component of the second.

Strftime ​

Alias for ToString.

fsharp
member Strftime(?format: string) : Expr

Parameters

NameTypeDescription
formatstring (optional)-

Time ​

Cast to Time (remove Date component).

fsharp
member Time : unit -> Expr

Timestamp ​

Convert to integer timestamp.

fsharp
member Timestamp(?timeUnit: TimeUnit) : Expr

Parameters

NameTypeDescription
timeUnitTimeUnit (optional)-

TotalDays ​

Extract the total days from a Duration type.

fsharp
member TotalDays(?fractional: bool) : Expr

Parameters

NameTypeDescription
fractionalbool (optional)Whether to include the fractional component of the day.

Returns: Expression/Series of data type Int64 or Float64 if fractional is set.


TotalHours ​

Extract the total hours from a Duration type.

fsharp
member TotalHours(?fractional: bool) : Expr

Parameters

NameTypeDescription
fractionalbool (optional)Whether to include the fractional component of the hour.

Returns: Expression/Series of data type Int64 or Float64 if fractional is set.


TotalMicroseconds ​

Extract the total microseconds from a Duration type.

fsharp
member TotalMicroseconds(?fractional: bool) : Expr

Parameters

NameTypeDescription
fractionalbool (optional)Whether to include the fractional component of the microsecond.

Returns: Expression/Series of data type Int64 or Float64 if fractional is set.


TotalMilliseconds ​

Extract the total milliseconds from a Duration type.

fsharp
member TotalMilliseconds(?fractional: bool) : Expr

Parameters

NameTypeDescription
fractionalbool (optional)Whether to include the fractional component of the millisecond.

Returns: Expression/Series of data type Int64 or Float64 if fractional is set.


TotalMinutes ​

Extract the total minutes from a Duration type.

fsharp
member TotalMinutes(?fractional: bool) : Expr

Parameters

NameTypeDescription
fractionalbool (optional)Whether to include the fractional component of the minute.

Returns: Expression/Series of data type Int64 or Float64 if fractional is set.


TotalNanoseconds ​

Extract the total nanoseconds from a Duration type.

fsharp
member TotalNanoseconds(?fractional: bool) : Expr

Parameters

NameTypeDescription
fractionalbool (optional)Whether to include return the result as a Float64. Because the smallest TimeUnit is 'ns', the fractional component will always be zero.

Returns: Expression/Series of data type Int64 or Float64 if fractional is set.


TotalSeconds ​

Extract the total seconds from a Duration type.

fsharp
member TotalSeconds(?fractional: bool) : Expr

Parameters

NameTypeDescription
fractionalbool (optional)Whether to include the fractional component of the second.

Returns: Expression/Series of data type Int64 or Float64 if fractional is set.


Truncate ​

Truncate dates to the specified interval (e.g., "1d", "1h", "15m").

fsharp
member Truncate(every: Dur) : Expr

Parameters

NameTypeDescription
everyDur-

Weekday ​

Get the weekday from the underlying date/datetime.

fsharp
member Weekday : unit -> Expr

Year ​

Get the year from the underlying date/datetime.

fsharp
member Year : unit -> Expr

Released under the MIT License. Powered by the Polars Rust core & Apache Arrow.