Discussion:
[pytables-users] ValueError: Trying to store a string with len [150] in [values_block_0] column but this column...
Evan
2016-10-10 06:52:00 UTC
Permalink
I am getting the following error after using `pandas.HDFStore().append()`

ValueError: Trying to store a string with len [150] in [values_block_0]
column but this column has a limit of [127]!

Consider using min_itemsize to preset the sizes on these columns

I am creating a pandas DataFrame and appending it to the HDF5 file as
follows:


import pandas as pd

store = pd.HDFStore("test1.h5", mode='w')


hdf_key = "one_key"

columns = ["col1", "col2", ... ]


df = pd.Dataframe(...)
df.col1 = df.col1.astype(str)
df.col2 = df.col2astype(int)

df.col3 = df.col3astype(str)
....

store.append(hdf_key, df, data_column=columns, index=False)

I get the error above: "ValueError: Trying to store a string with len [150]
in [values_block_0] column but this column has a limit of [127]!"

So, following this
StackOverflow http://stackoverflow.com/questions/22710738/pandas-pytable-how-to-specify-min-itemsize-of-the-elements-of-a-multiindex
, I tried

store.append(hdf_key, df, data_column=columns, index=False,
min_itemsize={"values_block_0":250})

This doesn't work though: I get this error:

ValueError: Trying to store a string with len [250] in [values_block_0]
column but this column has a limit of [127]!

Consider using min_itemsize to preset the sizes on these columns

What am I doing wrong?
--
You received this message because you are subscribed to the Google Groups "pytables-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pytables-users+***@googlegroups.com.
To post to this group, send an email to pytables-***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Francesc Alted
2016-10-10 07:36:43 UTC
Permalink
Hi Evan,

I'd say that this issue is more related to pandas, but if you can send a
pure PyTables example showing the problem, we could have a look at that
here.

Francesc
Post by Evan
I am getting the following error after using `pandas.HDFStore().append()`
ValueError: Trying to store a string with len [150] in
[values_block_0] column but this column has a limit of [127]!
Consider using min_itemsize to preset the sizes on these columns
I am creating a pandas DataFrame and appending it to the HDF5 file as
import pandas as pd
store = pd.HDFStore("test1.h5", mode='w')
hdf_key = "one_key"
columns = ["col1", "col2", ... ]
df = pd.Dataframe(...)
df.col1 = df.col1.astype(str)
df.col2 = df.col2astype(int)
df.col3 = df.col3astype(str)
....
store.append(hdf_key, df, data_column=columns, index=False)
I get the error above: "ValueError: Trying to store a string with len
[150] in [values_block_0] column but this column has a limit of [127]!"
So, following this StackOverflow http://stackoverflow.com/questions/
22710738/pandas-pytable-how-to-specify-min-itemsize-of-
the-elements-of-a-multiindex , I tried
store.append(hdf_key, df, data_column=columns, index=False,
min_itemsize={"values_block_0":250})
ValueError: Trying to store a string with len [250] in
[values_block_0] column but this column has a limit of [127]!
Consider using min_itemsize to preset the sizes on these columns
What am I doing wrong?
--
You received this message because you are subscribed to the Google Groups
"pytables-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
Francesc Alted
--
You received this message because you are subscribed to the Google Groups "pytables-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pytables-users+***@googlegroups.com.
To post to this group, send an email to pytables-***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Evan
2016-10-11 21:20:07 UTC
Permalink
Hi Francesc,

I also resolved this issue. The pandas parameter should be `data_columns`.
My error.

Thank you for the help, Evan
Post by Francesc Alted
Hi Evan,
I'd say that this issue is more related to pandas, but if you can send a
pure PyTables example showing the problem, we could have a look at that
here.
Francesc
Post by Evan
I am getting the following error after using `pandas.HDFStore().append()`
ValueError: Trying to store a string with len [150] in
[values_block_0] column but this column has a limit of [127]!
Consider using min_itemsize to preset the sizes on these columns
I am creating a pandas DataFrame and appending it to the HDF5 file as
import pandas as pd
store = pd.HDFStore("test1.h5", mode='w')
hdf_key = "one_key"
columns = ["col1", "col2", ... ]
df = pd.Dataframe(...)
df.col1 = df.col1.astype(str)
df.col2 = df.col2astype(int)
df.col3 = df.col3astype(str)
....
store.append(hdf_key, df, data_column=columns, index=False)
I get the error above: "ValueError: Trying to store a string with len
[150] in [values_block_0] column but this column has a limit of [127]!"
So, following this StackOverflow
http://stackoverflow.com/questions/22710738/pandas-pytable-how-to-specify-min-itemsize-of-the-elements-of-a-multiindex
, I tried
store.append(hdf_key, df, data_column=columns, index=False,
min_itemsize={"values_block_0":250})
ValueError: Trying to store a string with len [250] in
[values_block_0] column but this column has a limit of [127]!
Consider using min_itemsize to preset the sizes on these columns
What am I doing wrong?
--
You received this message because you are subscribed to the Google Groups
"pytables-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
<javascript:>.
For more options, visit https://groups.google.com/d/optout.
--
Francesc Alted
--
You received this message because you are subscribed to the Google Groups "pytables-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pytables-users+***@googlegroups.com.
To post to this group, send an email to pytables-***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...