webmaster-kazu.com

テクノロジー・データ分析・実践ログ・その他

「DeprecationWarning: scipy.sum is deprecated and will be removed in SciPy」の対処方法

カテゴリ: Python【初歩から現場実務的なもの】

「DeprecationWarning: scipy.sum is deprecated and will be removed in SciPy 2.0.0, use numpy.sum instead」というエラーの対処方法について解説します。

C:\Users\user_\AppData\Local\Temp\ipykernel_1152\1524554086.py:1: DeprecationWarning: scipy.sum is deprecated and will be removed in SciPy 2.0.0, use numpy.sum instead

sp.sum(fish_data)

■環境

Anaconda,Jupyter Notebook(Windows11)

Notebook上でnumpy,scipyモジュールをインポートした状態

■対処方法

■コード(修正前)

test_data = np.array([1,2,3,4,5,6])

sp.sum(test_data)

■コード(修正前)

test_data = np.array([1,2,3,4,5,6])

np.sum(test_data)

今回出力された警告は、scipy.sum関数が非推奨であり、SciPyの将来のバージョンで削除されることを示す内容です。代わりにnumpy.sumを使用することを勧めます。numpy.sumを使用することで問題が解消されます。