From 336cc6cba3188beb731b79ad55b1d86ddd0e25f0 Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Tue, 24 Nov 2020 19:58:18 -0800 Subject: [PATCH] BUG: pytables in py39 (#38041) * BUG: pytables in py39 * add pytables to py39 ci * whatsnew 1.1.5 * scipy and pyarrow to py39 build --- ci/deps/azure-39.yaml | 5 +++++ doc/source/whatsnew/v1.1.5.rst | 1 + pandas/core/computation/pytables.py | 4 ++++ pandas/tests/io/pytables/test_store.py | 2 +- 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ci/deps/azure-39.yaml b/ci/deps/azure-39.yaml index 67edc83a9d738..c4c84e73fa684 100644 --- a/ci/deps/azure-39.yaml +++ b/ci/deps/azure-39.yaml @@ -15,3 +15,8 @@ dependencies: - numpy - python-dateutil - pytz + + # optional dependencies + - pytables + - scipy + - pyarrow=1.0 diff --git a/doc/source/whatsnew/v1.1.5.rst b/doc/source/whatsnew/v1.1.5.rst index 609c3650c8cc2..dd88f79371d65 100644 --- a/doc/source/whatsnew/v1.1.5.rst +++ b/doc/source/whatsnew/v1.1.5.rst @@ -28,6 +28,7 @@ Bug fixes - Bug in metadata propagation for ``groupby`` iterator (:issue:`37343`) - Bug in indexing on a :class:`Series` with ``CategoricalDtype`` after unpickling (:issue:`37631`) - Bug in :class:`RollingGroupby` with the resulting :class:`MultiIndex` when grouping by a label that is in the index (:issue:`37641`) +- Bug in pytables methods in python 3.9 (:issue:`38041`) - .. --------------------------------------------------------------------------- diff --git a/pandas/core/computation/pytables.py b/pandas/core/computation/pytables.py index 6ec637a8b4845..0498d4d171c00 100644 --- a/pandas/core/computation/pytables.py +++ b/pandas/core/computation/pytables.py @@ -430,6 +430,10 @@ def visit_Subscript(self, node, **kwargs): except AttributeError: pass + if isinstance(slobj, Term): + # In py39 np.ndarray lookups with Term containing int raise + slobj = slobj.value + try: return self.const_type(value[slobj], self.env) except TypeError as err: diff --git a/pandas/tests/io/pytables/test_store.py b/pandas/tests/io/pytables/test_store.py index 32d1cf82c4330..afd2f56efb935 100644 --- a/pandas/tests/io/pytables/test_store.py +++ b/pandas/tests/io/pytables/test_store.py @@ -4462,7 +4462,7 @@ def test_categorical(self, setup_path): # Appending must have the same categories df3 = df.copy() - df3["s"].cat.remove_unused_categories(inplace=True) + df3["s"] = df3["s"].cat.remove_unused_categories() with pytest.raises(ValueError): store.append("df3", df3)