@@ -2211,12 +2211,6 @@ def take_data(self):
2211
2211
self .data , data = None , self .data
2212
2212
return data
2213
2213
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
-
2220
2214
def set_kind (self ):
2221
2215
# set my kind if we can
2222
2216
@@ -2248,7 +2242,6 @@ def set_kind(self):
2248
2242
def set_atom (
2249
2243
self ,
2250
2244
block ,
2251
- block_items ,
2252
2245
existing_col ,
2253
2246
min_itemsize ,
2254
2247
nan_rep ,
@@ -2258,13 +2251,15 @@ def set_atom(
2258
2251
):
2259
2252
""" create and setup my atom from the block b """
2260
2253
2261
- self .values = list (block_items )
2262
-
2263
2254
# short-cut certain block types
2264
2255
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
2266
2259
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
2268
2263
elif block .is_datetime :
2269
2264
return self .set_atom_datetime64 (block )
2270
2265
elif block .is_timedelta :
@@ -2292,13 +2287,7 @@ def set_atom(
2292
2287
# end up here ###
2293
2288
elif inferred_type == "string" or dtype == "object" :
2294
2289
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 ,
2302
2291
)
2303
2292
2304
2293
# set as a data block
@@ -2309,7 +2298,7 @@ def get_atom_string(self, block, itemsize):
2309
2298
return _tables ().StringCol (itemsize = itemsize , shape = block .shape [0 ])
2310
2299
2311
2300
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
2313
2302
):
2314
2303
# fill nan items with myself, don't disturb the blocks by
2315
2304
# trying to downcast
@@ -2324,13 +2313,14 @@ def set_atom_string(
2324
2313
2325
2314
# we cannot serialize this data, so report an exception on a column
2326
2315
# by column basis
2327
- for i , item in enumerate ( block_items ):
2316
+ for i in range ( len ( block . shape [ 0 ]) ):
2328
2317
2329
2318
col = block .iget (i )
2330
2319
inferred_type = lib .infer_dtype (col .ravel (), skipna = False )
2331
2320
if inferred_type != "string" :
2321
+ iloc = block .mgr_locs .indexer [i ]
2332
2322
raise TypeError (
2333
- f"Cannot serialize the column [{ item } ] because\n "
2323
+ f"Cannot serialize the column [{ iloc } ] because\n "
2334
2324
f"its data contents are [{ inferred_type } ] object dtype"
2335
2325
)
2336
2326
@@ -2383,7 +2373,7 @@ def set_atom_data(self, block):
2383
2373
self .typ = self .get_atom_data (block )
2384
2374
self .set_data (block .values .astype (self .typ .type , copy = False ))
2385
2375
2386
- def set_atom_categorical (self , block , items , info = None ):
2376
+ def set_atom_categorical (self , block ):
2387
2377
# currently only supports a 1-D categorical
2388
2378
# in a 1-D block
2389
2379
@@ -2393,8 +2383,6 @@ def set_atom_categorical(self, block, items, info=None):
2393
2383
self .dtype = codes .dtype .name
2394
2384
if values .ndim > 1 :
2395
2385
raise NotImplementedError ("only support 1-d categoricals" )
2396
- if len (items ) > 1 :
2397
- raise NotImplementedError ("only support single block categoricals" )
2398
2386
2399
2387
# write the codes; must be in a block shape
2400
2388
self .ordered = values .ordered
@@ -2403,10 +2391,7 @@ def set_atom_categorical(self, block, items, info=None):
2403
2391
2404
2392
# write the categories
2405
2393
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 ()
2410
2395
2411
2396
def get_atom_datetime64 (self , block ):
2412
2397
return _tables ().Int64Col (shape = block .shape [0 ])
@@ -2417,7 +2402,7 @@ def set_atom_datetime64(self, block):
2417
2402
values = block .values .view ("i8" )
2418
2403
self .set_data (values , "datetime64" )
2419
2404
2420
- def set_atom_datetime64tz (self , block , info ):
2405
+ def set_atom_datetime64tz (self , block ):
2421
2406
2422
2407
values = block .values
2423
2408
@@ -2426,7 +2411,6 @@ def set_atom_datetime64tz(self, block, info):
2426
2411
2427
2412
# store a converted timezone
2428
2413
self .tz = _get_tz (block .values .tz )
2429
- self .update_info (info )
2430
2414
2431
2415
self .kind = "datetime64"
2432
2416
self .typ = self .get_atom_datetime64 (block )
@@ -3917,9 +3901,9 @@ def get_blk_items(mgr, blocks):
3917
3901
existing_col = None
3918
3902
3919
3903
col = klass .create_for_block (i = i , name = name , version = self .version )
3904
+ col .values = list (b_items )
3920
3905
col .set_atom (
3921
3906
block = b ,
3922
- block_items = b_items ,
3923
3907
existing_col = existing_col ,
3924
3908
min_itemsize = min_itemsize ,
3925
3909
nan_rep = nan_rep ,
0 commit comments