@@ -233,8 +233,8 @@ def __repr__(self):
233
233
for k in self .keys ():
234
234
s = self .get_storer (k )
235
235
if s is not None :
236
- keys .append (str (s .pathname ))
237
- values .append (str (s ))
236
+ keys .append (str (s .pathname or k ))
237
+ values .append (str (s or 'invalid_HDFStore node' ))
238
238
239
239
output += adjoin (12 , keys , values )
240
240
else :
@@ -671,15 +671,22 @@ def copy(self, file, mode = 'w', propindexes = True, keys = None, complib = None
671
671
def _create_storer (self , group , value = None , table = False , append = False , ** kwargs ):
672
672
""" return a suitable Storer class to operate """
673
673
674
+ def error (t ):
675
+ raise Exception ("cannot properly create the storer for: [%s] [group->%s,value->%s,table->%s,append->%s,kwargs->%s]" %
676
+ (t ,group ,type (value ),table ,append ,kwargs ))
677
+
674
678
pt = getattr (group ._v_attrs ,'pandas_type' ,None )
675
679
tt = getattr (group ._v_attrs ,'table_type' ,None )
676
680
677
- # infer the typ from the passed value
681
+ # infer the pt from the passed value
678
682
if pt is None :
679
683
if value is None :
680
684
raise Exception ("cannot create a storer if the object is not existing nor a value are passed" )
681
685
682
- pt = _TYPE_MAP [type (value )]
686
+ try :
687
+ pt = _TYPE_MAP [type (value )]
688
+ except :
689
+ error ('_TYPE_MAP' )
683
690
684
691
# we are actually a table
685
692
if table or append :
@@ -690,8 +697,7 @@ def _create_storer(self, group, value = None, table = False, append = False, **k
690
697
try :
691
698
return globals ()[_STORER_MAP [pt ]](self , group , ** kwargs )
692
699
except :
693
- raise Exception ("cannot properly create the storer for: [group->%s,value->%s,table->%s,append->%s,kwargs->%s]" %
694
- (group ,value ,table ,append ,kwargs ))
700
+ error ('_STORER_MAP' )
695
701
696
702
# existing node (and must be a table)
697
703
if tt is None :
@@ -718,10 +724,9 @@ def _create_storer(self, group, value = None, table = False, append = False, **k
718
724
pass
719
725
720
726
try :
721
- return globals ()[_TABLE_MAP [tt or 'appendable_panel' ]](self , group , ** kwargs )
727
+ return globals ()[_TABLE_MAP [tt ]](self , group , ** kwargs )
722
728
except :
723
- raise Exception ("cannot properly create the storer for: [group->%s,value->%s,table->%s,append->%s,kwargs->%s]" %
724
- (group ,value ,table ,append ,kwargs ))
729
+ error ('_TABLE_MAP' )
725
730
726
731
def _write_to_group (self , key , value , index = True , table = False , append = False , complib = None , ** kwargs ):
727
732
group = self .get_node (key )
@@ -1834,12 +1839,13 @@ def __repr__(self):
1834
1839
if self .is_old_version :
1835
1840
ver = "[%s]" % '.' .join ([ str (x ) for x in self .version ])
1836
1841
1837
- return "%-12.12s%s (typ->%s,nrows->%s,indexers->[%s]%s)" % (self .pandas_type ,
1838
- ver ,
1839
- self .table_type_short ,
1840
- self .nrows ,
1841
- ',' .join ([ a .name for a in self .index_axes ]),
1842
- dc )
1842
+ return "%-12.12s%s (typ->%s,nrows->%s,ncols->%s,indexers->[%s]%s)" % (self .pandas_type ,
1843
+ ver ,
1844
+ self .table_type_short ,
1845
+ self .nrows ,
1846
+ self .ncols ,
1847
+ ',' .join ([ a .name for a in self .index_axes ]),
1848
+ dc )
1843
1849
1844
1850
def __getitem__ (self , c ):
1845
1851
""" return the axis for c """
@@ -1887,6 +1893,11 @@ def description(self):
1887
1893
def axes (self ):
1888
1894
return itertools .chain (self .index_axes , self .values_axes )
1889
1895
1896
+ @property
1897
+ def ncols (self ):
1898
+ """ the number of total columns in the values axes """
1899
+ return sum ([ len (a .values ) for a in self .values_axes ])
1900
+
1890
1901
@property
1891
1902
def is_transposed (self ):
1892
1903
return False
0 commit comments