polars_xdt.day_name#

polars_xdt.day_name(expr: str | Expr, locale: str | None = None) Expr#

Return day name, in specified locale (if specified).

Returns:
Expr

Expression of data type Utf8.

See also

format_localized

format according to locale.

Examples

>>> from datetime import datetime
>>> import polars_xdt as xdt
>>> df = pl.DataFrame(
...     {
...         "ts": [datetime(2020, 10, 25), datetime(2020, 10, 26)],
...     }
... )
>>> df.with_columns(
...     english_day_name=xdt.day_name("ts"),
...     french_day_name=xdt.day_name("ts", locale="fr_FR"),
...     ukrainian_day_name=xdt.day_name("ts", locale="uk_UA"),
... )
shape: (2, 4)
┌─────────────────────┬──────────────────┬─────────────────┬────────────────────┐
│ ts                  ┆ english_day_name ┆ french_day_name ┆ ukrainian_day_name │
│ ---                 ┆ ---              ┆ ---             ┆ ---                │
│ datetime[μs]        ┆ str              ┆ str             ┆ str                │
╞═════════════════════╪══════════════════╪═════════════════╪════════════════════╡
│ 2020-10-25 00:00:00 ┆ Sunday           ┆ dimanche        ┆ неділя             │
│ 2020-10-26 00:00:00 ┆ Monday           ┆ lundi           ┆ понеділок          │
└─────────────────────┴──────────────────┴─────────────────┴────────────────────┘