關(guān)于pandas-profiling的降級之旅
背景
做EDA分析,想要利用pandas-profling的集成工具,實現(xiàn)一鍵EDA自動化流程。
而pandas-profiling是python封裝好的庫,能夠使用DataFrame自動生成數(shù)據(jù)的詳細報告并能自動生成網(wǎng)頁進行可視化。
但理想和現(xiàn)實總是有差距,這個過程出現(xiàn)了很多error,主要原因都是由pandas-profiling的版本與環(huán)境不兼容導致的,謹以此文記入這些error和解決辦法供大家參考。
[Pandas-profiling] ImportError: cannot import name ‘ABCIndexClass’ from ‘pandas.core.dtypes.generic’
這是在安裝后的第一個報錯,發(fā)生于import pandas語句。
經(jīng)過調(diào)研,發(fā)現(xiàn)該問題是由于pip安裝時,會安裝pandas-profiling的最新版,但是:
Pandas v1.3 renamed the ABCIndexClass to ABCIndex.
The visions dependency of the pandas-profiling package hasn’t caught up yet, and so throws an error when it can’t find ABCIndexClass.
即pandas已經(jīng)升級了,但是pandas-profiling并沒升級,它們兩個中的同一個類有不同的類名對不上,所以出現(xiàn)了這個報錯。
解決辦法
Downgrading pandas to the 1.2.x series will resolve the issue.
我重新安裝了1.2.0版本的pandas-profiling包
module ‘pandas.core.common’ has no attribute ‘is_numeric_dtype’
這個時候import pandas-profiling不會再出現(xiàn)報錯了,可是report=ProfilieReport(df)這一步時會出現(xiàn)新的報錯。
經(jīng)過調(diào)研,發(fā)現(xiàn)該問題是由于:
pandas.core.common.is_numeric_dtype was removed in 0.23.
總的來說還是pandas的版本太高了,有兩種解決辦法:
- 一種就是降低pandas的等級至0.22
- 另一種就是自己重新配置一下pandas(不建議)。
代碼
from pandas_profiling import ProfileReport report=ProfileReport(df) report.to_file(output_file='output.html')
總結(jié)
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
使用Python進行數(shù)據(jù)可視化實現(xiàn)引人注目的視覺效果
這篇文章主要介紹了使用Python進行數(shù)據(jù)可視化實現(xiàn)引人注目的視覺效果,您將了解基本的數(shù)據(jù)可視化概念,以及如何創(chuàng)建各種引人注目的圖表和圖形,從而更好地理解和呈現(xiàn)數(shù)據(jù)2023-04-04
Python實現(xiàn)Excel批量處理+郵件自動發(fā)送的全流程
在日常辦公中,重復的 Excel 數(shù)據(jù)整理、報表生成與郵件分發(fā)工作占據(jù)大量時間,本文將手把手教你用 Python 實現(xiàn) Excel 數(shù)據(jù)批量處理 + 自動化郵件發(fā)送全流程,需要的朋友可以參考下2025-12-12
Python實現(xiàn)自動啟用惰性導入的實戰(zhàn)指南
Python 3.15 引入了一個新特性:lazy imports(惰性導入),它為加載緩慢的模塊提供了一種更高層次、也更正式的解決方案,下面小編就和大家詳細介紹一下如何在Python中動啟用惰性導入吧2026-04-04
python判斷一個集合是否包含了另外一個集合中所有項的方法
這篇文章主要介紹了python判斷一個集合是否包含了另外一個集合中所有項的方法,涉及Python集合操作的相關(guān)技巧,需要的朋友可以參考下2015-06-06
Python對文件和目錄進行操作的方法(file對象/os/os.path/shutil 模塊)
下面小編就為大家?guī)硪黄狿ython對文件和目錄進行操作的方法(file對象/os/os.path/shutil 模塊)。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-05-05

