赞
踩
pandas_profiling 官网(https://pypi.org/project/pandas-profiling/)大概在23年4月前发出如下公告:
pandas-profiling package naming was changed. To continue profiling data use ydata-profiling instead!
意味着pandas-profiling不能再用啦,要改用ydata-profiling,于是开始曲折的路径…
1. 下载ydata_profiling
在终端执行如下命令,下载ydata-profiling。用镜像下载可能快些。
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn ydata-profiling
需要的话,pip可能也要升级一下。
2. 跑得动ydata_profiling了,跑的过程中出错1:
调用的时候出错了,忘了什么原因,反正要求我upgrade pyodlc和tsfresh两个包,大家看起情况进行upgrade:
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade pyodbc
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade tsfresh
结果还要我upgrade 一个叫 typing-extensions的玩意儿:
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade typing-extensions
3. 跑得动ydata_profiling了,跑的过程中出错2:
错误如下:
jinja2.exceptions.TemplateSyntaxError: expected token 'end of statement block'
我在Pycharm执行的,然后顺着最终的错误点进了一个叫 table.html的文件,可能是渲染生成html的东西,看到pycharm提示如下错误:
错误 “Tag start is not closed” 是由于{% for value in row[‘value’] +%}中的+%导致的。Jinja2的for循环标记不需要+符号,因此可以移除它,修改前:
修改后:
然后就跑得动啦!代码很简单:
from ydata_profiling.profile_report import ProfileReport
import pandas as pd
data = pd.read_excel("./data.xls")
ProfileReport(data).to_file('./report.html')
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。