python data_error ai_generated true

ValueError:时间数据 '2024-13-45' 与格式 '%Y-%m-%d' 不匹配

ValueError: time data '2024-13-45' does not match format '%Y-%m-%d'

ID: python/pandas-parse-dates-error

其他格式: JSON · Markdown 中文 · English
80%修复率
87%置信度
0证据数
2024-06-03首次发现

版本兼容性

版本状态引入弃用备注
3.x active — — —

根因分析

日期字符串无效(月/日超出范围)或格式字符串不正确。

English

Date string is invalid (month/day out of range) or format string incorrect.

generic

解决方案

  1. 95% 成功率
    pd.to_datetime(s, errors='coerce') then inspect s.isna()
  2. 85% 成功率
    pd.to_datetime(s, format='mixed', dayfirst=False)

无效尝试

常见但无效的做法:

  1. 75% 失败

    Silently drops data; root data quality issue persists

  2. 85% 失败

    Produces wrong dates for valid rows