DateValue
DateValue(arg)
Attributes
Name | Description |
---|---|
add | Add an interval to a date. |
radd | Add an interval to a date. |
sub | Subtract a date or an interval from a date. |
Methods
Name | Description |
---|---|
delta | Compute the number of part s between two dates. |
epoch_days | Return the number of days since the UNIX epoch date. |
strftime | Format a date according to format_str . |
truncate | Truncate date expression to units of unit . |
delta
delta(other, part)
Compute the number of part
s between two dates.
The order of operands matches standard subtraction
The second argument is subtracted from the first.
Parameters
Name | Type | Description | Default |
---|---|---|---|
other | datetime.date | Value[dt.Date] | A date expression | required |
part | Literal['year', 'quarter', 'month', 'week', 'day'] | Value[dt.String] | The unit of time to compute the difference in | required |
Returns
Name | Type | Description |
---|---|---|
IntegerValue | The number of part s between self and other |
Examples
>>> import ibis
>>> ibis.options.interactive = True
>>> start = ibis.date("1992-09-30")
>>> end = ibis.date("1992-10-01")
>>> end.delta(start, unit="day")
>>> prez = ibis.examples.presidential.fetch()
>>> prez.mutate(
=prez.end.delta(prez.start, unit="year"),
... years_in_office=prez.end.delta(prez.start, unit="hour"),
... hours_in_office"party") ... ).drop(
epoch_days
epoch_days()
Return the number of days since the UNIX epoch date.
Examples
>>> import ibis
>>> ibis.options.interactive = True
>>> date = ibis.date(2020, 1, 1)
>>> date
>>> date.epoch_days()
>>> t = date.name("date_col").as_table()
>>> t
>>> t.mutate(epoch=t.date_col.epoch_days())
strftime
strftime(format_str)
Format a date according to format_str
.
Format string may depend on the backend, but we try to conform to ANSI strftime
.
Parameters
Name | Type | Description | Default |
---|---|---|---|
format_str | str | strftime format string |
required |
Returns
Name | Type | Description |
---|---|---|
StringValue | Formatted version of arg |
truncate
truncate(unit)
Truncate date expression to units of unit
.
Parameters
Name | Type | Description | Default |
---|---|---|---|
unit | Literal['Y', 'Q', 'M', 'W', 'D'] | Unit to truncate arg to |
required |
Returns
Name | Type | Description |
---|---|---|
DateValue | Truncated date value expression |