Skip to content

DOC: more informative PerformanceWarning in HDFStore #3623

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
May 16, 2013
Merged
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
12 changes: 8 additions & 4 deletions pandas/io/pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class AttributeConflictWarning(Warning): pass
class PerformanceWarning(Warning): pass
performance_doc = """
your performance may suffer as PyTables will pickle object types that it cannot map
directly to c-types [inferred_type->%s,key->%s]
directly to c-types [inferred_type->%s,key->%s] [items->%s]
"""

# map object types
Expand Down Expand Up @@ -1861,7 +1861,7 @@ def write_array_empty(self, key, value):
getattr(self.group, key)._v_attrs.value_type = str(value.dtype)
getattr(self.group, key)._v_attrs.shape = value.shape

def write_array(self, key, value):
def write_array(self, key, value, items=None):
if key in self.group:
self._handle.removeNode(self.group, key)

Expand Down Expand Up @@ -1904,7 +1904,11 @@ def write_array(self, key, value):
elif inferred_type == 'string':
pass
else:
ws = performance_doc % (inferred_type,key)
try:
items = list(items)
except:
pass
ws = performance_doc % (inferred_type,key,items)
warnings.warn(ws, PerformanceWarning)

vlarr = self._handle.createVLArray(self.group, key,
Expand Down Expand Up @@ -2115,7 +2119,7 @@ def write(self, obj, **kwargs):
for i in range(nblocks):
blk = data.blocks[i]
# I have no idea why, but writing values before items fixed #2299
self.write_array('block%d_values' % i, blk.values)
self.write_array('block%d_values' % i, blk.values, items=blk.items)
self.write_index('block%d_items' % i, blk.items)

class FrameStorer(BlockManagerStorer):
Expand Down