You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Pandas报错TypeError:NDFrame.describe()不支持datetime_is_numeric参数

错误原因与解决方法

错误原因

升级Pandas后出现该错误,是因为datetime_is_numeric这个参数在新版本Pandas(2.0及以上)中已被移除。旧版本Pandas里,该参数用于开启datetime类型数据的数值化统计计算;而新版本Pandas默认就会对datetime类型执行这类统计,不再需要该参数。

解决方法

  • 直接修改代码:删除describe()方法中的datetime_is_numeric=True参数即可,修改后代码如下:
    check_in_duration = df["Check-In Time"].describe()
    
  • 兼容新旧版本(可选):如果需要代码同时适配新旧Pandas版本,可以添加版本判断逻辑:
    import pandas as pd
    
    if pd.__version__ >= "2.0.0":
        check_in_duration = df["Check-In Time"].describe()
    else:
        check_in_duration = df["Check-In Time"].describe(datetime_is_numeric=True)
    

内容的提问来源于stack exchange,提问作者KleberQueiroz

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.17 09:57:02