Skip to content

BUG: IndexError in __repr__ #29681

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions pandas/core/computation/pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import ast
from functools import partial
from typing import Optional
from typing import Any, Optional, Tuple

import numpy as np

Expand Down Expand Up @@ -72,7 +72,6 @@ def __init__(self, op, lhs, rhs, queryables, encoding):
super().__init__(op, lhs, rhs)
self.queryables = queryables
self.encoding = encoding
self.filter = None
self.condition = None

def _disallow_scalar_only_bool_ops(self):
Expand Down Expand Up @@ -230,7 +229,11 @@ def convert_values(self):


class FilterBinOp(BinOp):
filter: Optional[Tuple[Any, Any, pd.Index]] = None

def __repr__(self) -> str:
if self.filter is None:
return "Filter: Not Initialized"
return pprint_thing(
"[Filter : [{lhs}] -> [{op}]".format(lhs=self.filter[0], op=self.filter[1])
)
Expand Down
37 changes: 14 additions & 23 deletions pandas/io/pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -3868,30 +3868,21 @@ def get_blk_items(mgr, blocks):
else:
existing_col = None

try:
col = klass.create_for_block(i=i, name=name, version=self.version)
col.set_atom(
block=b,
block_items=b_items,
existing_col=existing_col,
min_itemsize=min_itemsize,
nan_rep=nan_rep,
encoding=self.encoding,
errors=self.errors,
info=self.info,
)
col.set_pos(j)
col = klass.create_for_block(i=i, name=name, version=self.version)
col.set_atom(
block=b,
block_items=b_items,
existing_col=existing_col,
min_itemsize=min_itemsize,
nan_rep=nan_rep,
encoding=self.encoding,
errors=self.errors,
info=self.info,
)
col.set_pos(j)

self.values_axes.append(col)

self.values_axes.append(col)
except (NotImplementedError, ValueError, TypeError) as e:
raise e
except Exception as detail:
raise Exception(
"cannot find the correct atom type -> "
"[dtype->{name},items->{items}] {detail!s}".format(
name=b.dtype.name, items=b_items, detail=detail
)
)
j += 1

# validate our min_itemsize
Expand Down