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

执行profile=report(data)触发TypeError: 'module' object is not callable求助

问题解决:TypeError: 'module' object is not callable

错误原因

  • 导入方式错误:pandas_profiling中用于生成报告的可调用对象是ProfileReport类,你当前导入的profile_report是一个模块,无法直接调用。
  • 存在命名冲突:代码开头导入的profile模块,后续被同名变量覆盖,可能引发其他潜在问题。

修正后的代码

import pandas as pd
from pandas_profiling import ProfileReport  # 正确导入可调用的报告类

data = pd.read_csv(r"ifsc-code-of-syndicate-bank-_All-India_.csv")
print(data)

# 生成报告
profile_report = ProfileReport(data)  # 使用类创建报告实例,避免命名冲突
profile_report.to_file(output_file="ifsc.html")

额外说明

如果你使用的是pandas-profiling的最新版本(现已更名为ydata-profiling),安装包时需要执行pip install ydata-profiling,导入语句保持from ydata_profiling import ProfileReport即可,代码逻辑不变。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.17 23:25:25