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

Jupyter Lab及Google Colab中Pandas Profiling导入失败求助

解决Pandas Profiling导入错误的方案

核心原因

从3.0.0版本开始,pandas-profiling已正式更名为ydata-profiling,旧包名和导入逻辑不再维护。你遇到的两种错误都是版本不兼容或导入方式过时导致的:

  • 本地Jupyter的to_html报错:旧版pandas-profiling与当前Pandas版本不匹配
  • Colab的PandasProfiling导入失败:Colab默认安装的是新版包,但你仍使用旧的导入语句

统一修复步骤

1. 卸载旧版本

在终端(本地)或Colab代码单元格中执行:

pip uninstall -y pandas-profiling

2. 安装最新稳定版

pip install ydata-profiling

3. 正确导入并使用

替换原导入代码为:

from ydata_profiling import ProfileReport

生成并展示报告的示例代码:

import pandas as pd
# 加载你的数据集
df = pd.read_csv("your_dataset.csv")
# 生成报告
profile = ProfileReport(df, title="数据探查报告")
# 在Jupyter/Colab中直接展示
profile.to_notebook_iframe()
# 导出为HTML文件
profile.to_file("data_report.html")

旧版本兼容方案(不推荐)

如果必须使用旧版pandas-profiling,指定安装兼容的旧版本(如2.14.0,适配Pandas 1.x-2.x):

pip install pandas-profiling==2.14.0

此时导入语句为:

from pandas_profiling import ProfileReport
# 注意:旧版中不存在`PandasProfiling`类,你之前的导入语句本身有误

额外提示

  • Colab安装完成后需重启内核(点击菜单栏Runtime -> Restart runtime)再导入
  • Anaconda环境下可使用conda install -c conda-forge ydata-profiling安装,兼容性更佳

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.05 23:20:33