Landmaster
Landmaster

Reputation: 1053

pd.read_hdf throws 'cannot set WRITABLE flag to True of this array'

When running

pd.read_hdf('myfile.h5')

I get the following traceback error:

[[...some longer traceback]]

~/.local/lib/python3.6/site-packages/pandas/io/pytables.py in read_array(self, key, start, stop) 2487 2488 if isinstance(node, tables.VLArray): -> 2489 ret = node[0][start:stop] 2490 else: 2491 dtype = getattr(attrs, 'value_type', None)

~/.local/lib/python3.6/site-packages/tables/vlarray.py in getitem(self, key)

~/.local/lib/python3.6/site-packages/tables/vlarray.py in read(self, start, stop, step)

tables/hdf5extension.pyx in tables.hdf5extension.VLArray._read_array()

ValueError: cannot set WRITEABLE flag to True of this array

No clue what's going on. I've tried reinstalling tables, pandas everything basically, but doesn't want to read it.

Upvotes: 26

Views: 18771

Answers (3)

rkellerm
rkellerm

Reputation: 5512

Upgrading PyTables to version > 3.5.1 should solve this.

pip install --upgrade tables

Upvotes: 18

Nick Mortimer
Nick Mortimer

Reputation: 21

It seems that time-date strings were causing the problem and when I converted these from text to numpy (pd.to_datetime()) and stored the table and the problem went away so perhaps it has something to do with text data?

Upvotes: 0

Eddie Bell
Eddie Bell

Reputation: 226

Are you using numpy 1.16? It is incompatible with the latest release of pytables (see https://github.com/PyTables/PyTables/blob/v3.4.4/tables/hdf5extension.pyx#L2155) but the pytables team have not yet released a fixed version: https://github.com/PyTables/PyTables/issues/719

The only way I found to fix this is to downgrade numpy.

Upvotes: 21

Related Questions