關(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 實現(xiàn)docx與doc文件的互相轉(zhuǎn)換
這篇文章主要介紹了python 實現(xiàn)docx與doc文件的互相轉(zhuǎn)換操作,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2021-03-03使用Python快速實現(xiàn)鏈接轉(zhuǎn)word文檔
這篇文章主要為大家詳細介紹了如何使用Python快速實現(xiàn)鏈接轉(zhuǎn)word文檔功能,文中的示例代碼講解詳細,感興趣的小伙伴可以跟隨小編一起學習一下2025-02-02pytorch中關(guān)于distributedsampler函數(shù)的使用
這篇文章主要介紹了pytorch中關(guān)于distributedsampler函數(shù)的使用,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2023-02-02