pandasとopenpyxlで出現する”Value must be either numerical or a string containing a wild card”

python

pandasを使ってExcelを読み込むと、Value must be either numerical or a string containing a wild card”

突如このようなエラーに遭遇しました。

フィルターを解除して、再度読み込むとエラーがなくなります。

そして、openpyxlでフィルターを解除しようと、読み込もうとすると、同じエラーに遭遇します。

フィルター解除を手動でやりたくないので、この対処法を今日は記事にしたいと思います。

原因

まず、原因なのですが、どうやら、openpyxlのバージョン3.1.0で起きるようになっているみたいです。

そして、pandasはExcelファイルを読み込むときに、openpyxlを使用しています。

そのため、同じエラーが出てしまうようです。

参考記事

Getting "Value must be either numerical or a string containing a wildcard" exception when using version 3.1.0 (#1959) · Issues · openpyxl / openpyxl · GitLab
With latest openpyxl version, 3.1.0, I am getting the following exception while loading an excel file using pandas' read_excel() method: "Value must be either n...

対処法

私なりの対処法を記載します。

バージョンを3.1.0 → 3.0.10に戻しました。

なるべく最新のバージョンを使いたいのですが、方法がわからず、前バージョンに戻しました。

pip uninstall openpyxl

で、アンインストール可能です。

途中、実行するかどうか聞かれるので、そこはYを入力すると削除できます。

その後に、バージョンを指定してインストールします。

pip install openpyxl==3.0.10

これで、インストールができるはずです。

他にも解決策がある場合は教えていただけますと幸いです。

コメント