mirror of
https://github.com/apache/superset.git
synced 2026-05-12 19:35:17 +00:00
fix: coerce datetime conversion errors (#32683)
This commit is contained in:
committed by
Michael S. Molina
parent
4a189945d8
commit
8ba265ca2b
@@ -1680,18 +1680,26 @@ def normalize_dttm_col(
|
||||
utc=False,
|
||||
unit=unit,
|
||||
origin="unix",
|
||||
errors="raise",
|
||||
errors="coerce",
|
||||
exact=False,
|
||||
)
|
||||
else:
|
||||
# Column has already been formatted as a timestamp.
|
||||
df[_col.col_label] = dttm_series.apply(pd.Timestamp)
|
||||
try:
|
||||
df[_col.col_label] = dttm_series.apply(
|
||||
lambda x: pd.Timestamp(x) if pd.notna(x) else pd.NaT
|
||||
)
|
||||
except ValueError:
|
||||
logger.warning(
|
||||
"Unable to convert column %s to datetime, ignoring",
|
||||
_col.col_label,
|
||||
)
|
||||
else:
|
||||
df[_col.col_label] = pd.to_datetime(
|
||||
df[_col.col_label],
|
||||
utc=False,
|
||||
format=_col.timestamp_format,
|
||||
errors="raise",
|
||||
errors="coerce",
|
||||
exact=False,
|
||||
)
|
||||
if _col.offset:
|
||||
|
||||
Reference in New Issue
Block a user