@@ -258,29 +258,6 @@ def to_hdf(path_or_buf, key, value, mode=None, complevel=None, complib=None,
258
258
append = None , ** kwargs ):
259
259
""" store this object, close it if we opened it """
260
260
261
- # PyTables has some limitations that we need to check for
262
- if kwargs .get ('format' , None ) == 'table' :
263
- if value .columns .dtype .kind == 'S' :
264
- pass
265
- elif value .columns .dtype .kind == 'O' :
266
- # PyTables doesn't support Unicode columns, but types 'O' can still
267
- # contain unicode values so check for that
268
- for col in value .columns :
269
- try :
270
- col .encode ('ascii' ).decode ('ascii' )
271
- except UnicodeEncodeError :
272
- raise ValueError (
273
- "PyTables does not support UTF-8 column headers\n "
274
- "but header {} is at least not encodable to ASCII"
275
- .format (col )
276
- )
277
- else :
278
- raise ValueError (
279
- "Storing data in HDF with PyTables requires that the column\n "
280
- "types be of some string type or an object.\n "
281
- " Instead, your columns: {}\n "
282
- " are of type {}" .format (value .columns , value .columns .dtype ))
283
-
284
261
if append :
285
262
f = lambda store : store .append (key , value , ** kwargs )
286
263
else :
@@ -1559,6 +1536,12 @@ def maybe_set_size(self, min_itemsize=None, **kwargs):
1559
1536
self .typ = _tables (
1560
1537
).StringCol (itemsize = min_itemsize , pos = self .pos )
1561
1538
1539
+ def validate (self , handler , append , ** kwargs ):
1540
+ self .validate_names ()
1541
+
1542
+ def validate_names (self ):
1543
+ pass
1544
+
1562
1545
def validate_and_set (self , handler , append , ** kwargs ):
1563
1546
self .set_table (handler .table )
1564
1547
self .validate_col ()
@@ -2104,6 +2087,10 @@ class DataIndexableCol(DataCol):
2104
2087
""" represent a data column that can be indexed """
2105
2088
is_data_indexable = True
2106
2089
2090
+ def validate_names (self ):
2091
+ if not Index (self .values ).is_object ():
2092
+ raise ValueError ("cannot have non-object label DataIndexableCol" )
2093
+
2107
2094
def get_atom_string (self , block , itemsize ):
2108
2095
return _tables ().StringCol (itemsize = itemsize )
2109
2096
@@ -3776,6 +3763,9 @@ def write(self, obj, axes=None, append=False, complib=None,
3776
3763
min_itemsize = min_itemsize ,
3777
3764
** kwargs )
3778
3765
3766
+ for a in self .axes :
3767
+ a .validate (self , append )
3768
+
3779
3769
if not self .is_exists :
3780
3770
3781
3771
# create the table
0 commit comments