pandas read_hdf():ValueError cannot set WRITEABLE flag to True of this array

Published on:
Last updated:

This post is also available in: 日本語 (Japanese)

pandas を使っていて read_hdf() 関数で HDF5 ファイルを読み込むと下記のようなエラーが出る現象について、備忘録的にメモを書いています。

ValueError cannot set WRITEABLE flag to True of this array

調べてみた感じ、Pythonのライブラリ numpy と PyTables のバージョンの組み合わせが問題みたいなので、下記のコマンドで現状インストールされている PyTables のバージョン確認後、アップグレードを行い、エラーは解決しました。

Google Colaboratory を利用している場合、ランタイムの再起動にて変更が反映されるようです。
また、 numpy のバージョンを下げる事を試したところ、私のケースではGoogle Colaboratory のノートがクラッシュしましたので、あらかじめコピーを取った上で試してみる必要があるかもしれません。

#インストールされているPyTablesパッケージの詳細確認
pip show tables
#アップグレード
pip install --upgrade tables

参照元:
https://stackoverflow.com/questions/54210073/pd-read-hdf-throws-cannot-set-writable-flag-to-true-of-this-array

About
Kuniyoshi Takemoto is the founder of Amelt.net LLC, and editor of this blog(www.amelt.net).Learn more and follow me on LinkedIn.