>>> import ibis
>>> ibis.options.interactive = True
>>> start = ibis.date("1992-09-30")
>>> end = ibis.date("1992-10-01")
>>> end.delta(start, unit="day")
┌───┐
│ 1 │
└───┘
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. |
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 . |
Compute the number of part
s between two dates.
The second argument is subtracted from the first.
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 |
Name | Type | Description |
---|---|---|
IntegerValue | The number of part s between self and other |
>>> import ibis
>>> ibis.options.interactive = True
>>> start = ibis.date("1992-09-30")
>>> end = ibis.date("1992-10-01")
>>> end.delta(start, unit="day")
┌───┐
│ 1 │
└───┘
>>> prez = ibis.examples.presidential.fetch()
>>> prez.mutate(
... years_in_office=prez.end.delta(prez.start, unit="year"),
... hours_in_office=prez.end.delta(prez.start, unit="hour"),
... ).drop("party")
┏━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┓ ┃ name ┃ start ┃ end ┃ years_in_office ┃ hours_in_office ┃ ┡━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━┩ │ string │ date │ date │ int64 │ int64 │ ├────────────┼────────────┼────────────┼─────────────────┼─────────────────┤ │ Eisenhower │ 1953-01-20 │ 1961-01-20 │ 8 │ 70128 │ │ Kennedy │ 1961-01-20 │ 1963-11-22 │ 2 │ 24864 │ │ Johnson │ 1963-11-22 │ 1969-01-20 │ 6 │ 45264 │ │ Nixon │ 1969-01-20 │ 1974-08-09 │ 5 │ 48648 │ │ Ford │ 1974-08-09 │ 1977-01-20 │ 3 │ 21480 │ │ Carter │ 1977-01-20 │ 1981-01-20 │ 4 │ 35064 │ │ Reagan │ 1981-01-20 │ 1989-01-20 │ 8 │ 70128 │ │ Bush │ 1989-01-20 │ 1993-01-20 │ 4 │ 35064 │ │ Clinton │ 1993-01-20 │ 2001-01-20 │ 8 │ 70128 │ │ Bush │ 2001-01-20 │ 2009-01-20 │ 8 │ 70128 │ │ … │ … │ … │ … │ … │ └────────────┴────────────┴────────────┴─────────────────┴─────────────────┘
Return the number of days since the UNIX epoch date.
┌────────────┐
│ 2020-01-01 │
└────────────┘
┏━━━━━━━━━━━━┓ ┃ date_col ┃ ┡━━━━━━━━━━━━┩ │ date │ ├────────────┤ │ 2020-01-01 │ └────────────┘
Format a date according to format_str
.
Format string may depend on the backend, but we try to conform to ANSI strftime
.
Name | Type | Description | Default |
---|---|---|---|
format_str | str | strftime format string |
required |
Name | Type | Description |
---|---|---|
StringValue | Formatted version of arg |
Truncate date expression to units of unit
.
Name | Type | Description | Default |
---|---|---|---|
unit | Literal['Y', 'Q', 'M', 'W', 'D'] | Unit to truncate arg to |
required |
Name | Type | Description |
---|---|---|
DateValue | Truncated date value expression |