Spec-Zone.ru › Nushell

polars convert-time-zone for dataframe

Convert datetime to target timezone.

Signature

> polars convert-time-zone {flags} (time_zone)

Parameters

  • time_zone: Timezone for the Datetime Series. Pass null to unset time zone.

Input/output types:

input output
polars_expression polars_expression
polars_selector polars_expression

Examples

Convert timezone for timezone-aware datetime

> ["2025-04-10 09:30:00 -0400" "2025-04-10 10:30:00 -0400"] | polars into-df
                    | polars as-datetime "%Y-%m-%d %H:%M:%S %z"
                    | polars select (polars col datetime | polars convert-time-zone "Europe/Lisbon")
╭───┬────────────╮
│ # │  datetime  │
├───┼────────────┤
│ 0 │ a year ago │
│ 1 │ a year ago │
╰───┴────────────╯

Timezone conversions for timezone-naive datetime will assume the original timezone is UTC

> ["2025-04-10 09:30:00" "2025-04-10 10:30:00"] | polars into-df
                    | polars as-datetime "%Y-%m-%d %H:%M:%S" --naive
                    | polars select (polars col datetime | polars convert-time-zone "America/New_York")
╭───┬────────────╮
│ # │  datetime  │
├───┼────────────┤
│ 0 │ a year ago │
│ 1 │ a year ago │
╰───┴────────────╯

Copyright © 2019–2026 The Nushell Project DevelopersLicensed under the MIT License.
https://www.nushell.sh/commands/docs/polars_convert-time-zone.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API