Skip to content

Commit deceebe

Browse files
jbrockmendeljreback
authored andcommitted
BUG: IndexError in __repr__ (#29681)
1 parent 787ea54 commit deceebe

File tree

2 files changed

+19
-25
lines changed

2 files changed

+19
-25
lines changed

pandas/core/computation/pytables.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import ast
44
from functools import partial
5-
from typing import Optional
5+
from typing import Any, Optional, Tuple
66

77
import numpy as np
88

@@ -72,7 +72,6 @@ def __init__(self, op, lhs, rhs, queryables, encoding):
7272
super().__init__(op, lhs, rhs)
7373
self.queryables = queryables
7474
self.encoding = encoding
75-
self.filter = None
7675
self.condition = None
7776

7877
def _disallow_scalar_only_bool_ops(self):
@@ -230,7 +229,11 @@ def convert_values(self):
230229

231230

232231
class FilterBinOp(BinOp):
232+
filter: Optional[Tuple[Any, Any, pd.Index]] = None
233+
233234
def __repr__(self) -> str:
235+
if self.filter is None:
236+
return "Filter: Not Initialized"
234237
return pprint_thing(
235238
"[Filter : [{lhs}] -> [{op}]".format(lhs=self.filter[0], op=self.filter[1])
236239
)

pandas/io/pytables.py

+14-23
Original file line numberDiff line numberDiff line change
@@ -3868,30 +3868,21 @@ def get_blk_items(mgr, blocks):
38683868
else:
38693869
existing_col = None
38703870

3871-
try:
3872-
col = klass.create_for_block(i=i, name=name, version=self.version)
3873-
col.set_atom(
3874-
block=b,
3875-
block_items=b_items,
3876-
existing_col=existing_col,
3877-
min_itemsize=min_itemsize,
3878-
nan_rep=nan_rep,
3879-
encoding=self.encoding,
3880-
errors=self.errors,
3881-
info=self.info,
3882-
)
3883-
col.set_pos(j)
3871+
col = klass.create_for_block(i=i, name=name, version=self.version)
3872+
col.set_atom(
3873+
block=b,
3874+
block_items=b_items,
3875+
existing_col=existing_col,
3876+
min_itemsize=min_itemsize,
3877+
nan_rep=nan_rep,
3878+
encoding=self.encoding,
3879+
errors=self.errors,
3880+
info=self.info,
3881+
)
3882+
col.set_pos(j)
3883+
3884+
self.values_axes.append(col)
38843885

3885-
self.values_axes.append(col)
3886-
except (NotImplementedError, ValueError, TypeError) as e:
3887-
raise e
3888-
except Exception as detail:
3889-
raise Exception(
3890-
"cannot find the correct atom type -> "
3891-
"[dtype->{name},items->{items}] {detail!s}".format(
3892-
name=b.dtype.name, items=b_items, detail=detail
3893-
)
3894-
)
38953886
j += 1
38963887

38973888
# validate our min_itemsize

0 commit comments

Comments
 (0)