@@ -1895,6 +1895,7 @@ def __init__(
1895
1895
freq = None ,
1896
1896
tz = None ,
1897
1897
index_name = None ,
1898
+ ordered = None ,
1898
1899
table = None ,
1899
1900
meta = None ,
1900
1901
metadata = None ,
@@ -1913,6 +1914,7 @@ def __init__(
1913
1914
self .freq = freq
1914
1915
self .tz = tz
1915
1916
self .index_name = index_name
1917
+ self .ordered = ordered
1916
1918
self .table = table
1917
1919
self .meta = meta
1918
1920
self .metadata = metadata
@@ -2200,6 +2202,8 @@ def __init__(
2200
2202
typ = None ,
2201
2203
cname = None ,
2202
2204
pos = None ,
2205
+ tz = None ,
2206
+ ordered = None ,
2203
2207
table = None ,
2204
2208
meta = None ,
2205
2209
metadata = None ,
@@ -2211,6 +2215,8 @@ def __init__(
2211
2215
typ = typ ,
2212
2216
pos = pos ,
2213
2217
cname = cname ,
2218
+ tz = tz ,
2219
+ ordered = ordered ,
2214
2220
table = table ,
2215
2221
meta = meta ,
2216
2222
metadata = metadata ,
@@ -2270,15 +2276,6 @@ def take_data(self):
2270
2276
self .data , data = None , self .data
2271
2277
return data
2272
2278
2273
- def set_atom (self , block ):
2274
- """ create and setup my atom from the block b """
2275
-
2276
- # short-cut certain block types
2277
- if block .is_categorical :
2278
- self .set_atom_categorical (block )
2279
- elif block .is_datetimetz :
2280
- self .set_atom_datetime64tz (block )
2281
-
2282
2279
@classmethod
2283
2280
def _get_atom (cls , values : Union [np .ndarray , ABCExtensionArray ]) -> "Col" :
2284
2281
"""
@@ -2331,31 +2328,10 @@ def get_atom_coltype(cls, kind: str) -> Type["Col"]:
2331
2328
def get_atom_data (cls , shape , kind : str ) -> "Col" :
2332
2329
return cls .get_atom_coltype (kind = kind )(shape = shape [0 ])
2333
2330
2334
- def set_atom_categorical (self , block ):
2335
- # currently only supports a 1-D categorical
2336
- # in a 1-D block
2337
-
2338
- values = block .values
2339
-
2340
- if values .ndim > 1 :
2341
- raise NotImplementedError ("only support 1-d categoricals" )
2342
-
2343
- # write the codes; must be in a block shape
2344
- self .ordered = values .ordered
2345
-
2346
- # write the categories
2347
- self .meta = "category"
2348
- self .metadata = np .array (values .categories , copy = False ).ravel ()
2349
-
2350
2331
@classmethod
2351
2332
def get_atom_datetime64 (cls , shape ):
2352
2333
return _tables ().Int64Col (shape = shape [0 ])
2353
2334
2354
- def set_atom_datetime64tz (self , block ):
2355
-
2356
- # store a converted timezone
2357
- self .tz = _get_tz (block .values .tz )
2358
-
2359
2335
@classmethod
2360
2336
def get_atom_timedelta64 (cls , shape ):
2361
2337
return _tables ().Int64Col (shape = shape [0 ])
@@ -3880,6 +3856,13 @@ def get_blk_items(mgr, blocks):
3880
3856
3881
3857
typ = klass ._get_atom (data_converted )
3882
3858
kind = _dtype_to_kind (data_converted .dtype .name )
3859
+ tz = _get_tz (data_converted .tz ) if hasattr (data_converted , "tz" ) else None
3860
+
3861
+ meta = metadata = ordered = None
3862
+ if is_categorical_dtype (data_converted ):
3863
+ ordered = data_converted .ordered
3864
+ meta = "category"
3865
+ metadata = np .array (data_converted .categories , copy = False ).ravel ()
3883
3866
3884
3867
col = klass (
3885
3868
name = adj_name ,
@@ -3888,8 +3871,11 @@ def get_blk_items(mgr, blocks):
3888
3871
typ = typ ,
3889
3872
pos = j ,
3890
3873
kind = kind ,
3874
+ tz = tz ,
3875
+ ordered = ordered ,
3876
+ meta = meta ,
3877
+ metadata = metadata ,
3891
3878
)
3892
- col .set_atom (block = b )
3893
3879
col .set_data (data_converted )
3894
3880
col .update_info (self .info )
3895
3881
0 commit comments