Bug#972015: Bug#972033: python3.9 pandas

2020-10-18 Thread Rebecca N. Palmer

Control: tags -1 pending
Control: forwarded -1 https://github.com/pandas-dev/pandas/issues/37217


This appears to fix it, though I'm not yet sure if it's a good idea


I was trying to find upstream's fix and use that instead, but it now 
looks like they don't have one, and probably didn't know this bug existed.




Bug#972015: Bug#972033: python3.9 pandas

2020-10-17 Thread Rebecca N. Palmer

Control: tags -1 patch

The underlying cause (and reason this is 3.9-specific) appears to be the 
mostly-removal of ast.Index and its replacement by a bare value.


This appears to fix it, though I'm not yet sure if it's a good idea:

--- a/pandas/core/computation/pytables.py
+++ b/pandas/core/computation/pytables.py
@@ -425,6 +425,10 @@ class PyTablesExprVisitor(BaseExprVisito
 value = value.value
 except AttributeError:
 pass
+try:
+slobj = slobj.value
+except AttributeError:
+pass

 try:
 return self.const_type(value[slobj], self.env)



Bug#972015: Bug#972033: python3.9 pandas

2020-10-17 Thread Rebecca N. Palmer
This bug is not specific to DateTimeIndexes, and the immediate cause is 
the index being passed to numpy as a 
pandas.core.computation.pytables.Constant instead of an int:


$ python3.9
Python 3.9.0+ (default, Oct 16 2020, 17:57:59)
[GCC 10.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas as pd;from pandas.io.pytables import 
HDFStore;s1=HDFStore("tmp1.h5","w");df=pd.DataFrame([[1,2,3],[4,5,6]],columns=['A','B','C']);s1.append("d1",df,data_columns=["B"]);df2=s1.select("d1","index>df.index[0]");print(type(df2.index[0]))

Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python3/dist-packages/pandas/io/pytables.py", line 
876, in select

return it.get_result()
  File "/usr/lib/python3/dist-packages/pandas/io/pytables.py", line 
1930, in get_result

results = self.func(self.start, self.stop, where)
  File "/usr/lib/python3/dist-packages/pandas/io/pytables.py", line 
860, in func

return s.read(start=_start, stop=_stop, where=_where, columns=columns)
  File "/usr/lib/python3/dist-packages/pandas/io/pytables.py", line 
4483, in read

result = self._read_axes(where=where, start=start, stop=stop)
  File "/usr/lib/python3/dist-packages/pandas/io/pytables.py", line 
3682, in _read_axes

selection = Selection(self, where=where, start=start, stop=stop)
  File "/usr/lib/python3/dist-packages/pandas/io/pytables.py", line 
5167, in __init__

self.terms = self.generate(where)
  File "/usr/lib/python3/dist-packages/pandas/io/pytables.py", line 
5180, in generate

return PyTablesExpr(where, queryables=q, encoding=self.table.encoding)
  File 
"/usr/lib/python3/dist-packages/pandas/core/computation/pytables.py", 
line 573, in __init__

self.terms = self.parse()
  File 
"/usr/lib/python3/dist-packages/pandas/core/computation/expr.py", line 
806, in parse

return self._visitor.visit(self.expr)
  File 
"/usr/lib/python3/dist-packages/pandas/core/computation/expr.py", line 
398, in visit

return visitor(node, **kwargs)
  File 
"/usr/lib/python3/dist-packages/pandas/core/computation/expr.py", line 
404, in visit_Module

return self.visit(expr, **kwargs)
  File 
"/usr/lib/python3/dist-packages/pandas/core/computation/expr.py", line 
398, in visit

return visitor(node, **kwargs)
  File 
"/usr/lib/python3/dist-packages/pandas/core/computation/expr.py", line 
407, in visit_Expr

return self.visit(node.value, **kwargs)
  File 
"/usr/lib/python3/dist-packages/pandas/core/computation/expr.py", line 
398, in visit

return visitor(node, **kwargs)
  File 
"/usr/lib/python3/dist-packages/pandas/core/computation/expr.py", line 
699, in visit_Compare

return self.visit(binop)
  File 
"/usr/lib/python3/dist-packages/pandas/core/computation/expr.py", line 
398, in visit

return visitor(node, **kwargs)
  File 
"/usr/lib/python3/dist-packages/pandas/core/computation/expr.py", line 
520, in visit_BinOp

op, op_class, left, right = self._maybe_transform_eq_ne(node)
  File 
"/usr/lib/python3/dist-packages/pandas/core/computation/expr.py", line 
441, in _maybe_transform_eq_ne

right = self.visit(node.right, side="right")
  File 
"/usr/lib/python3/dist-packages/pandas/core/computation/expr.py", line 
398, in visit

return visitor(node, **kwargs)
  File 
"/usr/lib/python3/dist-packages/pandas/core/computation/pytables.py", 
line 430, in visit_Subscript

return self.const_type(value[slobj], self.env)
  File "/usr/lib/python3/dist-packages/pandas/core/indexes/range.py", 
line 720, in __getitem__

return super().__getitem__(key)
  File "/usr/lib/python3/dist-packages/pandas/core/indexes/base.py", 
line 4111, in __getitem__

result = getitem(key)
IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis 
(`None`) and integer or boolean arrays are valid indices

>>> import pdb;pdb.pm()
> 
/usr/lib/python3/dist-packages/pandas/core/indexes/base.py(4111)__getitem__()

-> result = getitem(key)
(Pdb) p key
0
(Pdb) p type(key)

(Pdb)