아미(아름다운미소)

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')  # 기본값 설정

'랭귀지 > pandas' 카테고리의 다른 글

type 함수  (0) 2025.04.03
index.duplicated() 메서드 사용  (0) 2025.03.31
pandas_profiling (대규모 데이터 분석)  (0) 2025.03.28
메모리 사용량을 상세히 분석  (0) 2025.03.28
df비교  (0) 2025.03.27
Comments