polars.Expr.dt.base_utc_offset#
- Expr.dt.base_utc_offset() Expr[source]#
与UTC的基本偏移量。
对于给定时区中的所有日期时间,这通常是恒定的,但在极少数情况下可能会有所不同,例如萨摩亚(阿皮亚)在2011年底切换时区时。
- Returns:
- Expr
数据类型
Duration的表达式。
另请参阅
Expr.dt.dst_offset夏令时与UTC的偏移量。
示例
>>> from datetime import datetime >>> df = pl.DataFrame( ... { ... "ts": [datetime(2011, 12, 29), datetime(2012, 1, 1)], ... } ... ) >>> df = df.with_columns(pl.col("ts").dt.replace_time_zone("Pacific/Apia")) >>> df.with_columns(pl.col("ts").dt.base_utc_offset().alias("base_utc_offset")) shape: (2, 2) ┌────────────────────────────┬─────────────────┐ │ ts ┆ base_utc_offset │ │ --- ┆ --- │ │ datetime[μs, Pacific/Apia] ┆ duration[ms] │ ╞════════════════════════════╪═════════════════╡ │ 2011-12-29 00:00:00 -10 ┆ -11h │ │ 2012-01-01 00:00:00 +14 ┆ 13h │ └────────────────────────────┴─────────────────┘