polars.Expr.dt.dst_offset#
- Expr.dt.dst_offset() Expr[source]#
当前生效的额外偏移量(通常是由于夏令时)。
- Returns:
- Expr
数据类型
Duration的表达式。
另请参阅
Expr.dt.base_utc_offset与UTC的基本偏移量。
示例
>>> from datetime import datetime >>> df = pl.DataFrame( ... { ... "ts": [datetime(2020, 10, 25), datetime(2020, 10, 26)], ... } ... ) >>> df = df.with_columns(pl.col("ts").dt.replace_time_zone("Europe/London")) >>> df.with_columns(pl.col("ts").dt.dst_offset().alias("dst_offset")) shape: (2, 2) ┌─────────────────────────────┬──────────────┐ │ ts ┆ dst_offset │ │ --- ┆ --- │ │ datetime[μs, Europe/London] ┆ duration[ms] │ ╞═════════════════════════════╪══════════════╡ │ 2020-10-25 00:00:00 BST ┆ 1h │ │ 2020-10-26 00:00:00 GMT ┆ 0ms │ └─────────────────────────────┴──────────────┘