Skip to content

daft.functions.minute#

minute #

minute(expr: Expression) -> Expression

Retrieves the minute for a datetime column.

Returns:

Name Type Description
Expression Expression

a UInt32 expression with just the minute extracted from a datetime column

Examples:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
>>> import datetime
>>> import daft
>>> from daft.functions import minute
>>> df = daft.from_pydict(
...     {
...         "x": [
...             datetime.datetime(2021, 1, 1, 5, 1, 1),
...             datetime.datetime(2021, 1, 2, 6, 1, 59),
...             datetime.datetime(2021, 1, 3, 7, 2, 0),
...         ],
...     }
... )
>>> df = df.with_column("minute", minute(df["x"]))
>>> df.show()
╭─────────────────────┬────────╮
│ x                   ┆ minute │
│ ---                 ┆ ---    │
│ Timestamp[us]       ┆ UInt32 │
╞═════════════════════╪════════╡
│ 2021-01-01 05:01:01 ┆ 1      │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┤
│ 2021-01-02 06:01:59 ┆ 1      │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┤
│ 2021-01-03 07:02:00 ┆ 2      │
╰─────────────────────┴────────╯
(Showing first 3 of 3 rows)
Source code in daft/functions/datetime.py
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
def minute(expr: Expression) -> Expression:
    """Retrieves the minute for a datetime column.

    Returns:
        Expression: a UInt32 expression with just the minute extracted from a datetime column

    Examples:
        >>> import datetime
        >>> import daft
        >>> from daft.functions import minute
        >>> df = daft.from_pydict(
        ...     {
        ...         "x": [
        ...             datetime.datetime(2021, 1, 1, 5, 1, 1),
        ...             datetime.datetime(2021, 1, 2, 6, 1, 59),
        ...             datetime.datetime(2021, 1, 3, 7, 2, 0),
        ...         ],
        ...     }
        ... )
        >>> df = df.with_column("minute", minute(df["x"]))
        >>> df.show()
        ╭─────────────────────┬────────╮
        │ x                   ┆ minute │
        │ ---                 ┆ ---    │
        │ Timestamp[us]       ┆ UInt32 │
        ╞═════════════════════╪════════╡
        │ 2021-01-01 05:01:01 ┆ 1      │
        ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┤
        │ 2021-01-02 06:01:59 ┆ 1      │
        ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┤
        │ 2021-01-03 07:02:00 ┆ 2      │
        ╰─────────────────────┴────────╯
        <BLANKLINE>
        (Showing first 3 of 3 rows)

    """
    return Expression._call_builtin_scalar_fn("minute", expr)