Skip to content

Wrong error message in HDFStore.append #22489

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

Closed
wants to merge 1 commit into from
Closed

Wrong error message in HDFStore.append #22489

wants to merge 1 commit into from

Conversation

bryanfree66
Copy link

Updated pytables.py to clarify error message when appending dataframe with None item in previously string-only column

@datapythonista datapythonista changed the title Fixes issue #16300 Wrong error message in HDFStore.append Aug 24, 2018
@datapythonista datapythonista added the IO HDF5 read_hdf, HDFStore label Aug 24, 2018
@datapythonista
Copy link
Member

@bryanfree66 can you run the issue case, and report the new error message please?

store = pd.HDFStore('teststore.h5', 'w')
chunk = pd.DataFrame({'V1':['a','b','c','d','e'], 'data': range(5)})
store.append('df', chunk)
chunk = pd.DataFrame({'V1':[None, None], 'data': [3, 5]})
store.append('df', chunk)

@bryanfree66
Copy link
Author

import pandas as pd
store = pd.HDFStore('teststore.h5', 'w')
chunk = pd.DataFrame({'V1':['a','b','c','d','e'], 'data': range(5)})
store.append('df', chunk)
chunk = pd.DataFrame({'V1':[None, None], 'data': [3, 5]})
store.append('df', chunk)
Traceback (most recent call last):
File "", line 1, in
File "/Users/bryan/code/pandas/pandas/io/pytables.py", line 988, in append
**kwargs)
File "/Users/bryan/code/pandas/pandas/io/pytables.py", line 1415, in _write_to_group
s.write(obj=value, append=append, complib=complib, **kwargs)
File "/Users/bryan/code/pandas/pandas/io/pytables.py", line 3996, in write
**kwargs)
File "/Users/bryan/code/pandas/pandas/io/pytables.py", line 3667, in create_axes
raise e
File "/Users/bryan/code/pandas/pandas/io/pytables.py", line 3662, in create_axes
info=self.info)
File "/Users/bryan/code/pandas/pandas/io/pytables.py", line 2001, in set_atom
errors)
File "/Users/bryan/code/pandas/pandas/io/pytables.py", line 2048, in set_atom_string
eci = existing_col.validate_col(itemsize)
File "/Users/bryan/code/pandas/pandas/io/pytables.py", line 1739, in validate_col
c.itemsize))
ValueError: Trying to store a string with len [3] in the column [V1], but
this column has a limit of [1]!
Consider using min_itemsize to preset the sizes on these columns

@jreback
Copy link
Contributor

jreback commented Aug 24, 2018

needs a test

@datapythonista
Copy link
Member

ValueError: Trying to store a string with len [3] in the column [V1], but
this column has a limit of [1]!
Consider using min_itemsize to preset the sizes on these columns

I don't think this error is correct. The example doesn't try to store a trying with len 3, is trying to store a None. Isn't that right?

@bryanfree66
Copy link
Author

bryanfree66 commented Aug 24, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
IO HDF5 read_hdf, HDFStore
Projects
None yet
3 participants