@@ -2211,12 +2211,6 @@ def take_data(self):
22112211 self .data , data = None , self .data
22122212 return data
22132213
2214- def set_metadata (self , metadata ):
2215- """ record the metadata """
2216- if metadata is not None :
2217- metadata = np .array (metadata , copy = False ).ravel ()
2218- self .metadata = metadata
2219-
22202214 def set_kind (self ):
22212215 # set my kind if we can
22222216
@@ -2248,7 +2242,6 @@ def set_kind(self):
22482242 def set_atom (
22492243 self ,
22502244 block ,
2251- block_items ,
22522245 existing_col ,
22532246 min_itemsize ,
22542247 nan_rep ,
@@ -2258,13 +2251,15 @@ def set_atom(
22582251 ):
22592252 """ create and setup my atom from the block b """
22602253
2261- self .values = list (block_items )
2262-
22632254 # short-cut certain block types
22642255 if block .is_categorical :
2265- return self .set_atom_categorical (block , items = block_items , info = info )
2256+ self .set_atom_categorical (block )
2257+ self .update_info (info )
2258+ return
22662259 elif block .is_datetimetz :
2267- return self .set_atom_datetime64tz (block , info = info )
2260+ self .set_atom_datetime64tz (block )
2261+ self .update_info (info )
2262+ return
22682263 elif block .is_datetime :
22692264 return self .set_atom_datetime64 (block )
22702265 elif block .is_timedelta :
@@ -2292,13 +2287,7 @@ def set_atom(
22922287 # end up here ###
22932288 elif inferred_type == "string" or dtype == "object" :
22942289 self .set_atom_string (
2295- block ,
2296- block_items ,
2297- existing_col ,
2298- min_itemsize ,
2299- nan_rep ,
2300- encoding ,
2301- errors ,
2290+ block , existing_col , min_itemsize , nan_rep , encoding , errors ,
23022291 )
23032292
23042293 # set as a data block
@@ -2309,7 +2298,7 @@ def get_atom_string(self, block, itemsize):
23092298 return _tables ().StringCol (itemsize = itemsize , shape = block .shape [0 ])
23102299
23112300 def set_atom_string (
2312- self , block , block_items , existing_col , min_itemsize , nan_rep , encoding , errors
2301+ self , block , existing_col , min_itemsize , nan_rep , encoding , errors
23132302 ):
23142303 # fill nan items with myself, don't disturb the blocks by
23152304 # trying to downcast
@@ -2324,13 +2313,14 @@ def set_atom_string(
23242313
23252314 # we cannot serialize this data, so report an exception on a column
23262315 # by column basis
2327- for i , item in enumerate ( block_items ):
2316+ for i in range ( len ( block . shape [ 0 ]) ):
23282317
23292318 col = block .iget (i )
23302319 inferred_type = lib .infer_dtype (col .ravel (), skipna = False )
23312320 if inferred_type != "string" :
2321+ iloc = block .mgr_locs .indexer [i ]
23322322 raise TypeError (
2333- f"Cannot serialize the column [{ item } ] because\n "
2323+ f"Cannot serialize the column [{ iloc } ] because\n "
23342324 f"its data contents are [{ inferred_type } ] object dtype"
23352325 )
23362326
@@ -2383,7 +2373,7 @@ def set_atom_data(self, block):
23832373 self .typ = self .get_atom_data (block )
23842374 self .set_data (block .values .astype (self .typ .type , copy = False ))
23852375
2386- def set_atom_categorical (self , block , items , info = None ):
2376+ def set_atom_categorical (self , block ):
23872377 # currently only supports a 1-D categorical
23882378 # in a 1-D block
23892379
@@ -2393,8 +2383,6 @@ def set_atom_categorical(self, block, items, info=None):
23932383 self .dtype = codes .dtype .name
23942384 if values .ndim > 1 :
23952385 raise NotImplementedError ("only support 1-d categoricals" )
2396- if len (items ) > 1 :
2397- raise NotImplementedError ("only support single block categoricals" )
23982386
23992387 # write the codes; must be in a block shape
24002388 self .ordered = values .ordered
@@ -2403,10 +2391,7 @@ def set_atom_categorical(self, block, items, info=None):
24032391
24042392 # write the categories
24052393 self .meta = "category"
2406- self .set_metadata (block .values .categories )
2407-
2408- # update the info
2409- self .update_info (info )
2394+ self .metadata = np .array (block .values .categories , copy = False ).ravel ()
24102395
24112396 def get_atom_datetime64 (self , block ):
24122397 return _tables ().Int64Col (shape = block .shape [0 ])
@@ -2417,7 +2402,7 @@ def set_atom_datetime64(self, block):
24172402 values = block .values .view ("i8" )
24182403 self .set_data (values , "datetime64" )
24192404
2420- def set_atom_datetime64tz (self , block , info ):
2405+ def set_atom_datetime64tz (self , block ):
24212406
24222407 values = block .values
24232408
@@ -2426,7 +2411,6 @@ def set_atom_datetime64tz(self, block, info):
24262411
24272412 # store a converted timezone
24282413 self .tz = _get_tz (block .values .tz )
2429- self .update_info (info )
24302414
24312415 self .kind = "datetime64"
24322416 self .typ = self .get_atom_datetime64 (block )
@@ -3917,9 +3901,9 @@ def get_blk_items(mgr, blocks):
39173901 existing_col = None
39183902
39193903 col = klass .create_for_block (i = i , name = name , version = self .version )
3904+ col .values = list (b_items )
39203905 col .set_atom (
39213906 block = b ,
3922- block_items = b_items ,
39233907 existing_col = existing_col ,
39243908 min_itemsize = min_itemsize ,
39253909 nan_rep = nan_rep ,
0 commit comments