Skip to content

Commit

Permalink
style
Browse files Browse the repository at this point in the history
  • Loading branch information
Colin Ho authored and Colin Ho committed Nov 1, 2024
1 parent 056dfe6 commit a1a9e9e
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions docs/source/user_guide/expressions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -601,21 +601,21 @@ You can perform arithmetic operations with timestamps and durations, such as add
.. code:: python
import datetime
df = daft.from_pydict({
"timestamp": [
datetime.datetime(2021, 1, 1, 0, 1, 1),
datetime.datetime(2021, 1, 1, 0, 1, 59),
datetime.datetime(2021, 1, 1, 0, 2, 0),
]
})
# Add 10 seconds to each timestamp
df = df.with_column(
"plus_10_seconds",
"plus_10_seconds",
df["timestamp"] + datetime.timedelta(seconds=10)
)
df.show()
.. group-tab:: ⚙️ SQL
Expand Down Expand Up @@ -645,7 +645,7 @@ You can perform arithmetic operations with timestamps and durations, such as add
.. code-block:: text
:caption: Output
╭───────────────────────────────┬───────────────────────────────╮
╭───────────────────────────────┬───────────────────────────────╮
│ timestamp ┆ plus_10_seconds │
│ --- ┆ --- │
│ Timestamp(Microseconds, None) ┆ Timestamp(Microseconds, None) │
Expand Down Expand Up @@ -718,7 +718,7 @@ The :meth:`.dt.* <daft.expressions.Expression.dt>` method namespace provides ext
.. code-block:: text
:caption: Output
╭───────────────────────────────┬───────┬────────┬────────┬────────┬────────┬────────╮
╭───────────────────────────────┬───────┬────────┬────────┬────────┬────────┬────────╮
│ timestamp ┆ year ┆ month ┆ day ┆ hour ┆ minute ┆ second │
│ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- │
│ Timestamp(Microseconds, None) ┆ Int32 ┆ UInt32 ┆ UInt32 ┆ UInt32 ┆ UInt32 ┆ UInt32 │
Expand Down Expand Up @@ -747,7 +747,7 @@ You can parse strings as timestamps with time zones and convert between differen
"2021-01-02 12:30:00.456 +0800"
]
})
# Parse the timestamp string with time zone and convert to New York time
df = df.with_column(
"ny_time",
Expand All @@ -769,7 +769,7 @@ You can parse strings as timestamps with time zones and convert between differen
"2021-01-02 12:30:00.456 +0800"
]
})
# Parse the timestamp string with time zone and convert to New York time
df = daft.sql("""
SELECT
Expand All @@ -783,7 +783,7 @@ You can parse strings as timestamps with time zones and convert between differen
.. code-block:: text
:caption: Output
╭───────────────────────────────┬───────────────────────────────────────────────────╮
╭───────────────────────────────┬───────────────────────────────────────────────────╮
│ timestamp_str ┆ ny_time │
│ --- ┆ --- │
│ Utf8 ┆ Timestamp(Milliseconds, Some("America/New_York")) │
Expand Down Expand Up @@ -819,13 +819,13 @@ For example, to truncate timestamps to the nearest hour:
"hour_start",
df["timestamp"].dt.truncate("1 hour")
)
df.show()
.. code-block:: text
:caption: Output
╭───────────────────────────────┬───────────────────────────────╮
╭───────────────────────────────┬───────────────────────────────╮
│ timestamp ┆ hour_start │
│ --- ┆ --- │
│ Timestamp(Microseconds, None) ┆ Timestamp(Microseconds, None) │
Expand All @@ -837,4 +837,4 @@ For example, to truncate timestamps to the nearest hour:
│ 2021-01-09 00:30:00 ┆ 2021-01-09 00:00:00 │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ 2021-01-10 01:59:59 ┆ 2021-01-10 01:00:00 │
╰───────────────────────────────┴───────────────────────────────╯
╰───────────────────────────────┴───────────────────────────────╯

0 comments on commit a1a9e9e

Please sign in to comment.