아미(아름다운미소)

errors='coerce'로 NaT 변환 후 처리 본문

랭귀지/pandas

errors='coerce'로 NaT 변환 후 처리

유키공 2025. 4. 1. 07:40
# 날짜 변환 (NULL → NaT)
dates = pd.to_datetime(df['a'], errors='coerce')

if not dates.empty and not pd.isna(dates.iloc[0]):
    first_date = dates.iloc[0]
else:
    first_date = pd.to_datetime('today')  # 기본값 설정
Comments