polars_xdt.month_name#

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

Return month 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, 11, 26)],
...     }
... )
>>> df.with_columns(
...     english_month_name=xdt.month_name("ts"),
...     french_month_name=xdt.month_name("ts", locale="fr_FR"),
...     ukrainian_month_name=xdt.month_name("ts", locale="uk_UA"),
... )
shape: (2, 4)
┌─────────────────────┬────────────────────┬───────────────────┬──────────────────────┐
│ ts                  ┆ english_month_name ┆ french_month_name ┆ ukrainian_month_name │
│ ---                 ┆ ---                ┆ ---               ┆ ---                  │
│ datetime[μs]        ┆ str                ┆ str               ┆ str                  │
╞═════════════════════╪════════════════════╪═══════════════════╪══════════════════════╡
│ 2020-10-25 00:00:00 ┆ October            ┆ octobre           ┆ жовтня               │
│ 2020-11-26 00:00:00 ┆ November           ┆ novembre          ┆ листопада            │
└─────────────────────┴────────────────────┴───────────────────┴──────────────────────┘