Skip to content

Commit 44a5683

Browse files
fix: Arrow timezone localization (#2411)
* Fix Arrow timezone localization * Avoid errors due to missing tz_convert method on arrow-backed types Signed-off-by: Anton Kukushkin <[email protected]> --------- Signed-off-by: Anton Kukushkin <[email protected]> Co-authored-by: jaidisido <[email protected]>
1 parent a887b20 commit 44a5683

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

awswrangler/_arrow.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from typing import Any, Dict, Optional, Tuple, cast
77

88
import pyarrow as pa
9+
import pytz
910

1011
import awswrangler.pandas as pd
1112
from awswrangler._data_types import athena2pyarrow
@@ -71,7 +72,8 @@ def _apply_timezone(df: pd.DataFrame, metadata: Dict[str, Any]) -> pd.DataFrame:
7172
_logger.debug("applying timezone (%s) on column %s", timezone, col_name)
7273
if hasattr(df[col_name].dtype, "tz") is False:
7374
df[col_name] = df[col_name].dt.tz_localize(tz="UTC")
74-
df[col_name] = df[col_name].dt.tz_convert(tz=timezone)
75+
if timezone is not None and timezone != pytz.UTC and hasattr(df[col_name].dt, "tz_convert"):
76+
df[col_name] = df[col_name].dt.tz_convert(tz=timezone)
7577
return df
7678

7779

0 commit comments

Comments
 (0)