>>> import ibis
>>> ibis.options.interactive = True
>>> start = ibis.time("01:58:00")
>>> end = ibis.time("23:59:59")
>>> end.delta(start, unit="hour")
┌────┐
│ 22 │
└────┘
Name | Description |
---|---|
add | Add an interval to a time expression. |
radd | Add an interval to a time expression. |
sub | Subtract a time or an interval from a time expression. |
Name | Description |
---|---|
delta | Compute the number of part s between two times. |
strftime | Format a time according to format_str . |
truncate | Truncate the expression to a time expression in units of unit . |
Compute the number of part
s between two times.
The second argument is subtracted from the first.
Name | Type | Description | Default |
---|---|---|---|
other | datetime.time | Value[dt.Time] | A time expression | required |
part | Literal['hour', 'minute', 'second', 'millisecond', 'microsecond', 'nanosecond'] | 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.time("01:58:00")
>>> end = ibis.time("23:59:59")
>>> end.delta(start, unit="hour")
┌────┐
│ 22 │
└────┘
>>> data = '''tpep_pickup_datetime,tpep_dropoff_datetime
... 2016-02-01T00:23:56,2016-02-01T00:42:28
... 2016-02-01T00:12:14,2016-02-01T00:21:41
... 2016-02-01T00:43:24,2016-02-01T00:46:14
... 2016-02-01T00:55:11,2016-02-01T01:24:34
... 2016-02-01T00:11:13,2016-02-01T00:16:59'''
>>> with open("/tmp/triptimes.csv", "w") as f:
... nbytes = f.write(data) # nbytes is unused
>>> taxi = ibis.read_csv("/tmp/triptimes.csv")
>>> ride_duration = (
... taxi.tpep_dropoff_datetime.time()
... .delta(taxi.tpep_pickup_datetime.time(), unit="minute")
... .name("ride_minutes")
... )
>>> ride_duration
┏━━━━━━━━━━━━━━┓ ┃ ride_minutes ┃ ┡━━━━━━━━━━━━━━┩ │ int64 │ ├──────────────┤ │ 19 │ │ 9 │ │ 3 │ │ 29 │ │ 5 │ └──────────────┘
Format a time 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 the expression to a time expression in units of unit
.
Commonly used for time series resampling.
Name | Type | Description | Default |
---|---|---|---|
unit | Literal['h', 'm', 's', 'ms', 'us', 'ns'] | The unit to truncate to | required |
Name | Type | Description |
---|---|---|
TimeValue | self truncated to unit |