σ
    LpjL}  γ                  σ    S SK Jr  S SKJrJrJr  S SKJrJr  \(       a  S SK	J
r
  S SKJr  \" SSS9r " S	 S
\\   5      rg)ι    )Ϊannotations)ΪTYPE_CHECKINGΪGenericΪTypeVar)ΪExprKindΪExprNode)ΪExpr)ΪTimeUnitΪExprTr	   )Ϊboundc                  σ   \ rS rSrSS jrSS jrSS jrSS jrSS jrSS jr	SS jr
SS	 jrSS
 jrSS jrSS jrSS jrSS jrSS jrSS jrSS jrSS jrSS jrSS jrSS jrS S jrS!S"S jjrS#S jrS$S jrSrg)%ΪExprDateTimeNamespaceι   c                σ    Xl         g )N©Ϊ_expr)ΪselfΪexprs     ΪL/var/www/html/pdf-tiff/venv/lib/python3.13/site-packages/narwhals/expr_dt.pyΪ__init__ΪExprDateTimeNamespace.__init__   s    Ψ
σ    c                σh    U R                   R                  [        [        R                  S5      5      $ )uΠ  Extract the date from underlying DateTime representation.

Raises:
    NotImplementedError: If pandas default backend is being used.

Examples:
    >>> from datetime import datetime
    >>> import polars as pl
    >>> import narwhals as nw
    >>> df_native = pl.DataFrame(
    ...     {"a": [datetime(2012, 1, 7, 10), datetime(2027, 12, 13)]}
    ... )
    >>> df = nw.from_native(df_native)
    >>> df.select(nw.col("a").dt.date()).to_native()
    shape: (2, 1)
    ββββββββββββββ
    β a          β
    β ---        β
    β date       β
    ββββββββββββββ‘
    β 2012-01-07 β
    β 2027-12-13 β
    ββββββββββββββ
zdt.date©r   Ϊ_append_noder   r   ΪELEMENTWISE©r   s    r   ΪdateΪExprDateTimeNamespace.date   s&    π2 zzΧ&Ρ&€x΄Χ0DΡ0DΐiΣ'PΣQΠQr   c                σh    U R                   R                  [        [        R                  S5      5      $ )u  Extract year from underlying DateTime representation.

Returns the year number in the calendar date.

Examples:
    >>> from datetime import datetime
    >>> import pandas as pd
    >>> import narwhals as nw
    >>> df_native = pd.DataFrame(
    ...     {"a": [datetime(1978, 6, 1), datetime(2065, 1, 1)]}
    ... )
    >>> df = nw.from_native(df_native)
    >>> df.with_columns(nw.col("a").dt.year().alias("year"))
    ββββββββββββββββββββ
    |Narwhals DataFrame|
    |------------------|
    |           a  year|
    |0 1978-06-01  1978|
    |1 2065-01-01  2065|
    ββββββββββββββββββββ
zdt.yearr   r   s    r   ΪyearΪExprDateTimeNamespace.year-   s&    π, zzΧ&Ρ&€x΄Χ0DΡ0DΐiΣ'PΣQΠQr   c                σh    U R                   R                  [        [        R                  S5      5      $ )aM  Extract month from underlying DateTime representation.

Returns the month number starting from 1. The return value ranges from 1 to 12.

Examples:
    >>> from datetime import datetime
    >>> import pyarrow as pa
    >>> import narwhals as nw
    >>> df_native = pa.table({"a": [datetime(1978, 6, 1), datetime(2065, 1, 1)]})
    >>> df = nw.from_native(df_native)
    >>> df.with_columns(nw.col("a").dt.month().alias("month")).to_native()
    pyarrow.Table
    a: timestamp[us]
    month: int64
    ----
    a: [[1978-06-01 00:00:00.000000,2065-01-01 00:00:00.000000]]
    month: [[6,1]]
zdt.monthr   r   s    r   ΪmonthΪExprDateTimeNamespace.monthE   s&    π& zzΧ&Ρ&€x΄Χ0DΡ0DΐjΣ'QΣRΠRr   c                σh    U R                   R                  [        [        R                  S5      5      $ )an  Extract day from underlying DateTime representation.

Returns the day of month starting from 1. The return value ranges from 1 to 31. (The last day of month differs by months.)

Examples:
    >>> from datetime import datetime
    >>> import pyarrow as pa
    >>> import narwhals as nw
    >>> df_native = pa.table({"a": [datetime(1978, 6, 1), datetime(2065, 1, 1)]})
    >>> df = nw.from_native(df_native)
    >>> df.with_columns(nw.col("a").dt.day().alias("day")).to_native()
    pyarrow.Table
    a: timestamp[us]
    day: int64
    ----
    a: [[1978-06-01 00:00:00.000000,2065-01-01 00:00:00.000000]]
    day: [[1,1]]
zdt.dayr   r   s    r   ΪdayΪExprDateTimeNamespace.dayZ   s&    π& zzΧ&Ρ&€x΄Χ0DΡ0DΐhΣ'OΣPΠPr   c                σh    U R                   R                  [        [        R                  S5      5      $ )uΣ  Extract hour from underlying DateTime representation.

Returns the hour number from 0 to 23.

Examples:
    >>> from datetime import datetime
    >>> import polars as pl
    >>> import narwhals as nw
    >>> df_native = pl.DataFrame(
    ...     {"a": [datetime(1978, 1, 1, 1), datetime(2065, 1, 1, 10)]}
    ... )
    >>> df = nw.from_native(df_native)
    >>> df.with_columns(nw.col("a").dt.hour().alias("hour"))
    ββββββββββββββββββββββββββββββββ
    |      Narwhals DataFrame      |
    |------------------------------|
    |shape: (2, 2)                 |
    |βββββββββββββββββββββββ¬βββββββ|
    |β a                   β hour β|
    |β ---                 β ---  β|
    |β datetime[ΞΌs]        β i8   β|
    |βββββββββββββββββββββββͺβββββββ‘|
    |β 1978-01-01 01:00:00 β 1    β|
    |β 2065-01-01 10:00:00 β 10   β|
    |βββββββββββββββββββββββ΄βββββββ|
    ββββββββββββββββββββββββββββββββ
zdt.hourr   r   s    r   ΪhourΪExprDateTimeNamespace.houro   s&    π8 zzΧ&Ρ&€x΄Χ0DΡ0DΐiΣ'PΣQΠQr   c                σh    U R                   R                  [        [        R                  S5      5      $ )a!  Extract minutes from underlying DateTime representation.

Returns the minute number from 0 to 59.

Examples:
    >>> from datetime import datetime
    >>> import pandas as pd
    >>> import narwhals as nw
    >>> df_native = pd.DataFrame(
    ...     {"a": [datetime(1978, 1, 1, 1, 1), datetime(2065, 1, 1, 10, 20)]}
    ... )
    >>> df = nw.from_native(df_native)
    >>> df.with_columns(nw.col("a").dt.minute().alias("minute")).to_native()
                        a  minute
    0 1978-01-01 01:01:00       1
    1 2065-01-01 10:20:00      20
z	dt.minuter   r   s    r   ΪminuteΪExprDateTimeNamespace.minute   s&    π$ zzΧ&Ρ&€x΄Χ0DΡ0DΐkΣ'RΣSΠSr   c                σh    U R                   R                  [        [        R                  S5      5      $ )a  Extract seconds from underlying DateTime representation.

Examples:
    >>> from datetime import datetime
    >>> import pyarrow as pa
    >>> import narwhals as nw
    >>> df_native = pa.table(
    ...     {
    ...         "a": [
    ...             datetime(1978, 1, 1, 1, 1, 1),
    ...             datetime(2065, 1, 1, 10, 20, 30),
    ...         ]
    ...     }
    ... )
    >>> df = nw.from_native(df_native)
    >>> df.with_columns(nw.col("a").dt.second().alias("second")).to_native()
    pyarrow.Table
    a: timestamp[us]
    second: int64
    ----
    a: [[1978-01-01 01:01:01.000000,2065-01-01 10:20:30.000000]]
    second: [[1,30]]
z	dt.secondr   r   s    r   ΪsecondΪExprDateTimeNamespace.second‘   s&    π0 zzΧ&Ρ&€x΄Χ0DΡ0DΐkΣ'RΣSΠSr   c                σh    U R                   R                  [        [        R                  S5      5      $ )aΐ  Extract milliseconds from underlying DateTime representation.

Examples:
    >>> from datetime import datetime
    >>> import pyarrow as pa
    >>> import narwhals as nw
    >>> df_native = pa.table(
    ...     {
    ...         "a": [
    ...             datetime(1978, 1, 1, 1, 1, 1, 0),
    ...             datetime(2065, 1, 1, 10, 20, 30, 67000),
    ...         ]
    ...     }
    ... )
    >>> df = nw.from_native(df_native)
    >>> df.with_columns(
    ...     nw.col("a").dt.millisecond().alias("millisecond")
    ... ).to_native()
    pyarrow.Table
    a: timestamp[us]
    millisecond: int64
    ----
    a: [[1978-01-01 01:01:01.000000,2065-01-01 10:20:30.067000]]
    millisecond: [[0,67]]
zdt.millisecondr   r   s    r   ΪmillisecondΪ!ExprDateTimeNamespace.millisecond»   σ'    π4 zzΧ&Ρ&€x΄Χ0DΡ0DΠFVΣ'WΣXΠXr   c                σh    U R                   R                  [        [        R                  S5      5      $ )aΓ  Extract microseconds from underlying DateTime representation.

Examples:
    >>> from datetime import datetime
    >>> import pyarrow as pa
    >>> import narwhals as nw
    >>> df_native = pa.table(
    ...     {
    ...         "a": [
    ...             datetime(1978, 1, 1, 1, 1, 1, 0),
    ...             datetime(2065, 1, 1, 10, 20, 30, 67000),
    ...         ]
    ...     }
    ... )
    >>> df = nw.from_native(df_native)
    >>> df.with_columns(
    ...     nw.col("a").dt.microsecond().alias("microsecond")
    ... ).to_native()
    pyarrow.Table
    a: timestamp[us]
    microsecond: int64
    ----
    a: [[1978-01-01 01:01:01.000000,2065-01-01 10:20:30.067000]]
    microsecond: [[0,67000]]
zdt.microsecondr   r   s    r   ΪmicrosecondΪ!ExprDateTimeNamespace.microsecondΧ   r5   r   c                σh    U R                   R                  [        [        R                  S5      5      $ )aΑ  Extract Nanoseconds from underlying DateTime representation.

Examples:
    >>> from datetime import datetime
    >>> import pyarrow as pa
    >>> import narwhals as nw
    >>> df_native = pa.table(
    ...     {
    ...         "a": [
    ...             datetime(1978, 1, 1, 1, 1, 1, 0),
    ...             datetime(2065, 1, 1, 10, 20, 30, 67000),
    ...         ]
    ...     }
    ... )
    >>> df = nw.from_native(df_native)
    >>> df.with_columns(
    ...     nw.col("a").dt.nanosecond().alias("nanosecond")
    ... ).to_native()
    pyarrow.Table
    a: timestamp[us]
    nanosecond: int64
    ----
    a: [[1978-01-01 01:01:01.000000,2065-01-01 10:20:30.067000]]
    nanosecond: [[0,67000000]]
zdt.nanosecondr   r   s    r   Ϊ
nanosecondΪ ExprDateTimeNamespace.nanosecondσ   s&    π4 zzΧ&Ρ&€x΄Χ0DΡ0DΐoΣ'VΣWΠWr   c                σh    U R                   R                  [        [        R                  S5      5      $ )u΅  Get ordinal day.

Examples:
    >>> from datetime import datetime
    >>> import pandas as pd
    >>> import narwhals as nw
    >>> df_native = pd.DataFrame(
    ...     {"a": [datetime(2020, 1, 1), datetime(2020, 8, 3)]}
    ... )
    >>> df = nw.from_native(df_native)
    >>> df.with_columns(a_ordinal_day=nw.col("a").dt.ordinal_day())
    βββββββββββββββββββββββββββββ
    |    Narwhals DataFrame     |
    |---------------------------|
    |           a  a_ordinal_day|
    |0 2020-01-01              1|
    |1 2020-08-03            216|
    βββββββββββββββββββββββββββββ
zdt.ordinal_dayr   r   s    r   Ϊordinal_dayΪ!ExprDateTimeNamespace.ordinal_day  s'    π( zzΧ&Ρ&€x΄Χ0DΡ0DΠFVΣ'WΣXΠXr   c                σh    U R                   R                  [        [        R                  S5      5      $ )uΰ  Extract the week day from the underlying Date representation.

Note that Monday = 1 and Sunday = 7.

Examples:
    >>> from datetime import datetime
    >>> import pandas as pd
    >>> import narwhals as nw
    >>> df_native = pd.DataFrame(
    ...     {"a": [datetime(2020, 1, 1), datetime(2020, 8, 3)]}
    ... )
    >>> df = nw.from_native(df_native)
    >>> df.with_columns(a_week_day=nw.col("a").dt.weekday())
    ββββββββββββββββββββββββββ
    |   Narwhals DataFrame   |
    |------------------------|
    |           a  a_week_day|
    |0 2020-01-01           3|
    |1 2020-08-03           1|
    ββββββββββββββββββββββββββ
z
dt.weekdayr   r   s    r   ΪweekdayΪExprDateTimeNamespace.weekday%  s&    π, zzΧ&Ρ&€x΄Χ0DΡ0DΐlΣ'SΣTΠTr   c                σh    U R                   R                  [        [        R                  S5      5      $ )u  Get total minutes.

Notes:
    The function outputs the total minutes in the int dtype by default,
    however, pandas may change the dtype to float when there are missing values,
    consider using `fill_null()` and `cast` in this case.

Examples:
    >>> from datetime import timedelta
    >>> import polars as pl
    >>> import narwhals as nw
    >>> df_native = pl.DataFrame(
    ...     {"a": [timedelta(minutes=10), timedelta(minutes=20, seconds=40)]}
    ... )
    >>> df = nw.from_native(df_native)
    >>> df.with_columns(
    ...     a_total_minutes=nw.col("a").dt.total_minutes()
    ... ).to_native()
    shape: (2, 2)
    ββββββββββββββββ¬ββββββββββββββββββ
    β a            β a_total_minutes β
    β ---          β ---             β
    β duration[ΞΌs] β i64             β
    ββββββββββββββββͺββββββββββββββββββ‘
    β 10m          β 10              β
    β 20m 40s      β 20              β
    ββββββββββββββββ΄ββββββββββββββββββ
zdt.total_minutesr   r   s    r   Ϊtotal_minutesΪ#ExprDateTimeNamespace.total_minutes=  σ'    π: zzΧ&Ρ&€x΄Χ0DΡ0DΠFXΣ'YΣZΠZr   c                σh    U R                   R                  [        [        R                  S5      5      $ )u  Get total seconds.

Notes:
    The function outputs the total seconds in the int dtype by default,
    however, pandas may change the dtype to float when there are missing values,
    consider using `fill_null()` and `cast` in this case.

Examples:
    >>> from datetime import timedelta
    >>> import polars as pl
    >>> import narwhals as nw
    >>> df_native = pl.DataFrame(
    ...     {"a": [timedelta(seconds=10), timedelta(seconds=20, milliseconds=40)]}
    ... )
    >>> df = nw.from_native(df_native)
    >>> df.with_columns(
    ...     a_total_seconds=nw.col("a").dt.total_seconds()
    ... ).to_native()
    shape: (2, 2)
    ββββββββββββββββ¬ββββββββββββββββββ
    β a            β a_total_seconds β
    β ---          β ---             β
    β duration[ΞΌs] β i64             β
    ββββββββββββββββͺββββββββββββββββββ‘
    β 10s          β 10              β
    β 20s 40ms     β 20              β
    ββββββββββββββββ΄ββββββββββββββββββ
zdt.total_secondsr   r   s    r   Ϊtotal_secondsΪ#ExprDateTimeNamespace.total_seconds\  rE   r   c                σh    U R                   R                  [        [        R                  S5      5      $ )u]  Get total milliseconds.

Notes:
    The function outputs the total milliseconds in the int dtype by default,
    however, pandas may change the dtype to float when there are missing values,
    consider using `fill_null()` and `cast` in this case.

Examples:
    >>> from datetime import timedelta
    >>> import polars as pl
    >>> import narwhals as nw
    >>> df_native = pl.DataFrame(
    ...     {
    ...         "a": [
    ...             timedelta(milliseconds=10),
    ...             timedelta(milliseconds=20, microseconds=40),
    ...         ]
    ...     }
    ... )
    >>> df = nw.from_native(df_native)
    >>> df.with_columns(
    ...     a_total_milliseconds=nw.col("a").dt.total_milliseconds()
    ... ).to_native()
    shape: (2, 2)
    ββββββββββββββββ¬βββββββββββββββββββββββ
    β a            β a_total_milliseconds β
    β ---          β ---                  β
    β duration[ΞΌs] β i64                  β
    ββββββββββββββββͺβββββββββββββββββββββββ‘
    β 10ms         β 10                   β
    β 20040Β΅s      β 20                   β
    ββββββββββββββββ΄βββββββββββββββββββββββ
zdt.total_millisecondsr   r   s    r   Ϊtotal_millisecondsΪ(ExprDateTimeNamespace.total_milliseconds{  s-    πD zzΧ&Ρ&άXΧ)Ρ)Π+BΣCσ
π 	
r   c                σh    U R                   R                  [        [        R                  S5      5      $ )af  Get total microseconds.

Notes:
    The function outputs the total microseconds in the int dtype by default,
    however, pandas may change the dtype to float when there are missing values,
    consider using `fill_null()` and `cast` in this case.

Examples:
    >>> from datetime import timedelta
    >>> import pyarrow as pa
    >>> import narwhals as nw
    >>> df_native = pa.table(
    ...     {
    ...         "a": [
    ...             timedelta(microseconds=10),
    ...             timedelta(milliseconds=1, microseconds=200),
    ...         ]
    ...     }
    ... )
    >>> df = nw.from_native(df_native)
    >>> df.with_columns(
    ...     a_total_microseconds=nw.col("a").dt.total_microseconds()
    ... ).to_native()
    pyarrow.Table
    a: duration[us]
    a_total_microseconds: int64
    ----
    a: [[10,1200]]
    a_total_microseconds: [[10,1200]]
zdt.total_microsecondsr   r   s    r   Ϊtotal_microsecondsΪ(ExprDateTimeNamespace.total_microseconds‘  s,    π> zzΧ&Ρ&άXΧ)Ρ)Π+BΣCσ
π 	
r   c                σh    U R                   R                  [        [        R                  S5      5      $ )aή  Get total nanoseconds.

Notes:
    The function outputs the total nanoseconds in the int dtype by default,
    however, pandas may change the dtype to float when there are missing values,
    consider using `fill_null()` and `cast` in this case.

Examples:
    >>> from datetime import timedelta
    >>> import pandas as pd
    >>> import narwhals as nw
    >>> df_native = pd.DataFrame(
    ...     {
    ...         "a": pd.to_datetime(
    ...             [
    ...                 "2024-01-01 00:00:00.000000001",
    ...                 "2024-01-01 00:00:00.000000002",
    ...             ]
    ...         )
    ...     }
    ... )
    >>> df = nw.from_native(df_native)
    >>> df.with_columns(
    ...     a_diff_total_nanoseconds=nw.col("a").diff().dt.total_nanoseconds()
    ... ).to_native()
                                  a  a_diff_total_nanoseconds
    0 2024-01-01 00:00:00.000000001                       NaN
    1 2024-01-01 00:00:00.000000002                       1.0
zdt.total_nanosecondsr   r   s    r   Ϊtotal_nanosecondsΪ'ExprDateTimeNamespace.total_nanosecondsΔ  s,    π< zzΧ&Ρ&άXΧ)Ρ)Π+AΣBσ
π 	
r   c                σf    U R                   R                  [        [        R                  SUS95      $ )u7	  Convert a Date/Time/Datetime column into a String column with the given format.

Arguments:
    format: Format to format temporal column with.

Notes:
    Unfortunately, different libraries interpret format directives a bit
    differently.

    - Chrono, the library used by Polars, uses `"%.f"` for fractional seconds,
      whereas pandas and Python stdlib use `".%f"`.
    - PyArrow interprets `"%S"` as "seconds, including fractional seconds"
      whereas most other tools interpret it as "just seconds, as 2 digits".
    ---
    Therefore, we make the following adjustments.

    - for pandas-like libraries, we replace `"%S.%f"` with `"%S%.f"`.
    - for PyArrow, we replace `"%S.%f"` with `"%S"`.
    ---
    Workarounds like these don't make us happy, and we try to avoid them as
    much as possible, but here we feel like it's the best compromise.

    If you just want to format a date/datetime Series as a local datetime
    string, and have it work as consistently as possible across libraries,
    we suggest using:

    - `"%Y-%m-%dT%H:%M:%S%.f"` for datetimes
    - `"%Y-%m-%d"` for dates
    ---
    Though note that, even then, different tools may return a different number
    of trailing zeros. Nonetheless, this is probably consistent enough for
    most applications.

    If you have an application where this is not enough, please open an issue
    and let us know.

Examples:
    >>> from datetime import datetime
    >>> import polars as pl
    >>> import narwhals as nw
    >>> df_native = pl.DataFrame(
    ...     {"a": [datetime(2020, 3, 1), datetime(2020, 5, 1)]}
    ... )
    >>> df = nw.from_native(df_native)
    >>> df.select(nw.col("a").dt.to_string("%Y/%m/%d %H:%M:%S"))
    βββββββββββββββββββββββββ
    |  Narwhals DataFrame   |
    |-----------------------|
    |shape: (2, 1)          |
    |βββββββββββββββββββββββ|
    |β a                   β|
    |β ---                 β|
    |β str                 β|
    |βββββββββββββββββββββββ‘|
    |β 2020/03/01 00:00:00 β|
    |β 2020/05/01 00:00:00 β|
    |βββββββββββββββββββββββ|
    βββββββββββββββββββββββββ
zdt.to_string)Ϊformatr   )r   rS   s     r   Ϊ	to_stringΪExprDateTimeNamespace.to_stringζ  s.    πx zzΧ&Ρ&άXΧ)Ρ)¨>ΐ&ΡIσ
π 	
r   c                σf    U R                   R                  [        [        R                  SUS95      $ )a}  Replace time zone.

Arguments:
    time_zone: Target time zone.

Examples:
    >>> from datetime import datetime, timezone
    >>> import pandas as pd
    >>> import narwhals as nw
    >>> df_native = pd.DataFrame(
    ...     {
    ...         "a": [
    ...             datetime(2024, 1, 1, tzinfo=timezone.utc),
    ...             datetime(2024, 1, 2, tzinfo=timezone.utc),
    ...         ]
    ...     }
    ... )
    >>> df = nw.from_native(df_native)
    >>> df.select(nw.col("a").dt.replace_time_zone("Asia/Kathmandu")).to_native()
                              a
    0 2024-01-01 00:00:00+05:45
    1 2024-01-02 00:00:00+05:45
zdt.replace_time_zone©Ϊ	time_zoner   )r   rX   s     r   Ϊreplace_time_zoneΪ'ExprDateTimeNamespace.replace_time_zone&  s.    π0 zzΧ&Ρ&άXΧ)Ρ)Π+AΘYΡWσ
π 	
r   c                σ    Uc  Sn[        U5      eU R                  R                  [        [        R
                  SUS95      $ )aη  Convert to a new time zone.

If converting from a time-zone-naive column, then conversion happens
as if converting from UTC.

Arguments:
    time_zone: Target time zone.

Examples:
    >>> from datetime import datetime, timezone
    >>> import pandas as pd
    >>> import narwhals as nw
    >>> df_native = pd.DataFrame(
    ...     {
    ...         "a": [
    ...             datetime(2024, 1, 1, tzinfo=timezone.utc),
    ...             datetime(2024, 1, 2, tzinfo=timezone.utc),
    ...         ]
    ...     }
    ... )
    >>> df = nw.from_native(df_native)
    >>> df.select(nw.col("a").dt.convert_time_zone("Asia/Kathmandu")).to_native()
                              a
    0 2024-01-01 05:45:00+05:45
    1 2024-01-02 05:45:00+05:45
zTarget `time_zone` cannot be `None` in `convert_time_zone`. Please use `replace_time_zone(None)` if you want to remove the time zone.zdt.convert_time_zonerW   )Ϊ	TypeErrorr   r   r   r   r   )r   rX   Ϊmsgs      r   Ϊconvert_time_zoneΪ'ExprDateTimeNamespace.convert_time_zoneB  sF    π6 Ρπ ZCάC.Π ΨzzΧ&Ρ&άXΧ)Ρ)Π+AΘYΡWσ
π 	
r   c                σ    US;  a  SU< S3n[        U5      eU R                  R                  [        [        R
                  SUS95      $ )uγ  Return a timestamp in the given time unit.

Arguments:
    time_unit: One of
        - 'ns': nanosecond.
        - 'us': microsecond.
        - 'ms': millisecond.

Examples:
    >>> from datetime import date
    >>> import polars as pl
    >>> import narwhals as nw
    >>> df_native = pl.DataFrame({"date": [date(2001, 1, 1), None]})
    >>> df = nw.from_native(df_native)
    >>> df.with_columns(nw.col("date").dt.timestamp("ms").alias("timestamp_ms"))
    βββββββββββββββββββββββββββββββ
    |     Narwhals DataFrame      |
    |-----------------------------|
    |shape: (2, 2)                |
    |ββββββββββββββ¬βββββββββββββββ|
    |β date       β timestamp_ms β|
    |β ---        β ---          β|
    |β date       β i64          β|
    |ββββββββββββββͺβββββββββββββββ‘|
    |β 2001-01-01 β 978307200000 β|
    |β null       β null         β|
    |ββββββββββββββ΄βββββββββββββββ|
    βββββββββββββββββββββββββββββββ
>   ΪmsΪnsΪusz=invalid `time_unit`

Expected one of {'ns', 'us', 'ms'}, got Ϊ.zdt.timestamp)Ϊ	time_unit)Ϊ
ValueErrorr   r   r   r   r   )r   re   r]   s      r   Ϊ	timestampΪExprDateTimeNamespace.timestampd  sZ    π< Π.Σ.πAΨAJΑΘQπPπ τ S/Π!ΨzzΧ&Ρ&άXΧ)Ρ)¨>ΐYΡOσ
π 	
r   c                σf    U R                   R                  [        [        R                  SUS95      $ )uQ  Divide the date/datetime range into buckets.

Arguments:
    every: Length of bucket. Must be of form `<multiple><unit>`,
        where `multiple` is a positive integer and `unit` is one of

        - 'ns': nanosecond.
        - 'us': microsecond.
        - 'ms': millisecond.
        - 's': second.
        - 'm': minute.
        - 'h': hour.
        - 'd': day.
        - 'mo': month.
        - 'q': quarter.
        - 'y': year.

Examples:
    >>> from datetime import datetime
    >>> import polars as pl
    >>> import narwhals as nw
    >>> df_native = pl.DataFrame({"datetime": [datetime(2021, 3, 1, 12, 34)]})
    >>> df = nw.from_native(df_native)
    >>> df.with_columns(
    ...     nw.col("datetime").dt.truncate("1h").alias("datetime_trunc")
    ... )
    βββββββββββββββββββββββββββββββββββββββββββββββ
    |             Narwhals DataFrame              |
    |---------------------------------------------|
    |shape: (1, 2)                                |
    |βββββββββββββββββββββββ¬ββββββββββββββββββββββ|
    |β datetime            β datetime_trunc      β|
    |β ---                 β ---                 β|
    |β datetime[ΞΌs]        β datetime[ΞΌs]        β|
    |βββββββββββββββββββββββͺββββββββββββββββββββββ‘|
    |β 2021-03-01 12:34:00 β 2021-03-01 12:00:00 β|
    |βββββββββββββββββββββββ΄ββββββββββββββββββββββ|
    βββββββββββββββββββββββββββββββββββββββββββββββ
zdt.truncate)Ϊeveryr   )r   rj   s     r   ΪtruncateΪExprDateTimeNamespace.truncate  s.    πP zzΧ&Ρ&άXΧ)Ρ)¨=ΐΡFσ
π 	
r   c                σf    U R                   R                  [        [        R                  SUS95      $ )u_  Offset this date by a relative time offset.

Arguments:
    by: The offset. Must be of form `<multiple><unit>`,
        where `multiple` is a positive integer and `unit` is one of

        - 'ns': nanosecond.
        - 'us': microsecond.
        - 'ms': millisecond.
        - 's': second.
        - 'm': minute.
        - 'h': hour.
        - 'd': day.
        - 'mo': month.
        - 'q': quarter.
        - 'y': year.

Notes:
    For the Ibis backend, offsetting timezone-aware data by a calendar
    unit ('d', 'mo', 'q' or 'y') raises: Ibis stores such values as UTC,
    so the result would diverge from other backends across DST transitions.

Examples:
    >>> from datetime import datetime
    >>> import polars as pl
    >>> import narwhals as nw
    >>> df_native = pl.DataFrame({"datetime": [datetime(2021, 3, 1, 12, 34)]})
    >>> df = nw.from_native(df_native)
    >>> df.with_columns(
    ...     nw.col("datetime").dt.offset_by("1h").alias("datetime_offset_by_1h")
    ... )
    βββββββββββββββββββββββββββββββββββββββββββββββββ
    |              Narwhals DataFrame               |
    |-----------------------------------------------|
    |shape: (1, 2)                                  |
    |βββββββββββββββββββββββ¬ββββββββββββββββββββββββ|
    |β datetime            β datetime_offset_by_1h β|
    |β ---                 β ---                   β|
    |β datetime[ΞΌs]        β datetime[ΞΌs]          β|
    |βββββββββββββββββββββββͺββββββββββββββββββββββββ‘|
    |β 2021-03-01 12:34:00 β 2021-03-01 13:34:00   β|
    |βββββββββββββββββββββββ΄ββββββββββββββββββββββββ|
    βββββββββββββββββββββββββββββββββββββββββββββββββ
zdt.offset_by)Ϊbyr   )r   rn   s     r   Ϊ	offset_byΪExprDateTimeNamespace.offset_byΈ  s.    πZ zzΧ&Ρ&άXΧ)Ρ)¨>ΈbΡAσ
π 	
r   r   N)r   r   ΪreturnΪNone)rq   r   )rS   Ϊstrrq   r   )rX   z
str | Nonerq   r   )rX   rs   rq   r   )rc   )re   r
   rq   r   )rj   rs   rq   r   )rn   rs   rq   r   )Ϊ__name__Ϊ
__module__Ϊ__qualname__Ϊ__firstlineno__r   r   r!   r$   r'   r*   r-   r0   r3   r7   r:   r=   r@   rC   rG   rJ   rM   rP   rT   rY   r^   rg   rk   ro   Ϊ__static_attributes__© r   r   r   r      s    ττRτ6Rτ0Sτ*Qτ*Rτ<Tτ(Tτ4Yτ8Yτ8Xτ8Yτ,Uτ0[τ>[τ>$
τL!
τF 
τD>
τ@
τ8 
φD&
τP*
χX/
r   r   N)Ϊ
__future__r   Ϊtypingr   r   r   Ϊnarwhals._expression_parsingr   r   Ϊnarwhals.exprr	   Ϊnarwhals.typingr
   r   r   ry   r   r   Ϊ<module>r      s8   πέ "η 2Ρ 2η ;ζέ"έ(αvΡ&τY
G ENυ Y
r   