@@ -106,7 +106,7 @@ class Block(PandasObject):
106
106
_holder = None
107
107
_concatenator = staticmethod (np .concatenate )
108
108
109
- def __init__ (self , values , placement , ndim = None , fastpath = False ):
109
+ def __init__ (self , values , placement , ndim = None ):
110
110
if ndim is None :
111
111
ndim = values .ndim
112
112
elif values .ndim != ndim :
@@ -206,7 +206,7 @@ def array_dtype(self):
206
206
"""
207
207
return self .dtype
208
208
209
- def make_block (self , values , placement = None , ndim = None , ** kwargs ):
209
+ def make_block (self , values , placement = None , ndim = None ):
210
210
"""
211
211
Create a new block, with type inference propagate any values that are
212
212
not specified
@@ -216,21 +216,20 @@ def make_block(self, values, placement=None, ndim=None, **kwargs):
216
216
if ndim is None :
217
217
ndim = self .ndim
218
218
219
- return make_block (values , placement = placement , ndim = ndim , ** kwargs )
219
+ return make_block (values , placement = placement , ndim = ndim )
220
220
221
- def make_block_scalar (self , values , ** kwargs ):
221
+ def make_block_scalar (self , values ):
222
222
"""
223
223
Create a ScalarBlock
224
224
"""
225
225
return ScalarBlock (values )
226
226
227
- def make_block_same_class (self , values , placement = None , fastpath = True ,
228
- ** kwargs ):
227
+ def make_block_same_class (self , values , placement = None , ndim = None ):
229
228
""" Wrap given values in a block of same type as self. """
230
229
if placement is None :
231
230
placement = self .mgr_locs
232
- return make_block (values , placement = placement , klass = self . __class__ ,
233
- fastpath = fastpath , ** kwargs )
231
+ return make_block (values , placement = placement , ndim = ndim ,
232
+ klass = self . __class__ )
234
233
235
234
def __unicode__ (self ):
236
235
@@ -341,7 +340,7 @@ def reindex_axis(self, indexer, method=None, axis=1, fill_value=None,
341
340
342
341
new_values = algos .take_nd (self .values , indexer , axis ,
343
342
fill_value = fill_value , mask_info = mask_info )
344
- return self .make_block (new_values , fastpath = True )
343
+ return self .make_block (new_values )
345
344
346
345
def iget (self , i ):
347
346
return self .values [i ]
@@ -460,7 +459,7 @@ def make_a_block(nv, ref_loc):
460
459
except (AttributeError , NotImplementedError ):
461
460
pass
462
461
block = self .make_block (values = nv ,
463
- placement = ref_loc , fastpath = True )
462
+ placement = ref_loc )
464
463
return block
465
464
466
465
# ndim == 1
@@ -519,7 +518,7 @@ def downcast(self, dtypes=None, mgr=None):
519
518
dtypes = 'infer'
520
519
521
520
nv = maybe_downcast_to_dtype (values , dtypes )
522
- return self .make_block (nv , fastpath = True )
521
+ return self .make_block (nv )
523
522
524
523
# ndim > 1
525
524
if dtypes is None :
@@ -910,7 +909,7 @@ def _is_empty_indexer(indexer):
910
909
911
910
# coerce and try to infer the dtypes of the result
912
911
values = self ._try_coerce_and_cast_result (values , dtype )
913
- block = self .make_block (transf (values ), fastpath = True )
912
+ block = self .make_block (transf (values ))
914
913
return block
915
914
916
915
def putmask (self , mask , new , align = True , inplace = False , axis = 0 ,
@@ -1026,7 +1025,7 @@ def f(m, v, i):
1026
1025
if transpose :
1027
1026
new_values = new_values .T
1028
1027
1029
- return [self .make_block (new_values , fastpath = True )]
1028
+ return [self .make_block (new_values )]
1030
1029
1031
1030
def coerce_to_target_dtype (self , other ):
1032
1031
"""
@@ -1161,7 +1160,7 @@ def _interpolate_with_fill(self, method='pad', axis=0, inplace=False,
1161
1160
dtype = self .dtype )
1162
1161
values = self ._try_coerce_result (values )
1163
1162
1164
- blocks = [self .make_block (values , klass = self .__class__ , fastpath = True )]
1163
+ blocks = [self .make_block_same_class (values , ndim = self .ndim )]
1165
1164
return self ._maybe_downcast (blocks , downcast )
1166
1165
1167
1166
def _interpolate (self , method = None , index = None , values = None ,
@@ -1201,8 +1200,7 @@ def func(x):
1201
1200
# interp each column independently
1202
1201
interp_values = np .apply_along_axis (func , axis , data )
1203
1202
1204
- blocks = [self .make_block (interp_values , klass = self .__class__ ,
1205
- fastpath = True )]
1203
+ blocks = [self .make_block_same_class (interp_values )]
1206
1204
return self ._maybe_downcast (blocks , downcast )
1207
1205
1208
1206
def take_nd (self , indexer , axis , new_mgr_locs = None , fill_tuple = None ):
@@ -1246,7 +1244,7 @@ def take_nd(self, indexer, axis, new_mgr_locs=None, fill_tuple=None):
1246
1244
def diff (self , n , axis = 1 , mgr = None ):
1247
1245
""" return block for the diff of the values """
1248
1246
new_values = algos .diff (self .values , n , axis = axis )
1249
- return [self .make_block (values = new_values , fastpath = True )]
1247
+ return [self .make_block (values = new_values )]
1250
1248
1251
1249
def shift (self , periods , axis = 0 , mgr = None ):
1252
1250
""" shift the block by periods, possibly upcast """
@@ -1276,7 +1274,7 @@ def shift(self, periods, axis=0, mgr=None):
1276
1274
if f_ordered :
1277
1275
new_values = new_values .T
1278
1276
1279
- return [self .make_block (new_values , fastpath = True )]
1277
+ return [self .make_block (new_values )]
1280
1278
1281
1279
def eval (self , func , other , errors = 'raise' , try_cast = False , mgr = None ):
1282
1280
"""
@@ -1416,7 +1414,7 @@ def handle_error():
1416
1414
result = self ._try_cast_result (result )
1417
1415
1418
1416
result = _block_shape (result , ndim = self .ndim )
1419
- return [self .make_block (result , fastpath = True , )]
1417
+ return [self .make_block (result )]
1420
1418
1421
1419
def where (self , other , cond , align = True , errors = 'raise' ,
1422
1420
try_cast = False , axis = 0 , transpose = False , mgr = None ):
@@ -1696,7 +1694,7 @@ class NonConsolidatableMixIn(object):
1696
1694
_validate_ndim = False
1697
1695
_holder = None
1698
1696
1699
- def __init__ (self , values , placement , ndim = None , fastpath = False , ** kwargs ):
1697
+ def __init__ (self , values , placement , ndim = None ):
1700
1698
1701
1699
# Placement must be converted to BlockPlacement via property setter
1702
1700
# before ndim logic, because placement may be a slice which doesn't
@@ -1953,12 +1951,12 @@ class TimeDeltaBlock(DatetimeLikeBlockMixin, IntBlock):
1953
1951
_can_hold_na = True
1954
1952
is_numeric = False
1955
1953
1956
- def __init__ (self , values , placement , fastpath = False , ** kwargs ):
1954
+ def __init__ (self , values , placement , ndim = None ):
1957
1955
if values .dtype != _TD_DTYPE :
1958
1956
values = conversion .ensure_timedelta64ns (values )
1959
1957
1960
- super (TimeDeltaBlock , self ).__init__ (values , fastpath = True ,
1961
- placement = placement , ** kwargs )
1958
+ super (TimeDeltaBlock , self ).__init__ (values ,
1959
+ placement = placement , ndim = ndim )
1962
1960
1963
1961
@property
1964
1962
def _box_func (self ):
@@ -2091,13 +2089,12 @@ class ObjectBlock(Block):
2091
2089
is_object = True
2092
2090
_can_hold_na = True
2093
2091
2094
- def __init__ (self , values , ndim = 2 , fastpath = False , placement = None ,
2095
- ** kwargs ):
2092
+ def __init__ (self , values , placement = None , ndim = 2 ):
2096
2093
if issubclass (values .dtype .type , compat .string_types ):
2097
2094
values = np .array (values , dtype = object )
2098
2095
2099
- super (ObjectBlock , self ).__init__ (values , ndim = ndim , fastpath = fastpath ,
2100
- placement = placement , ** kwargs )
2096
+ super (ObjectBlock , self ).__init__ (values , ndim = ndim ,
2097
+ placement = placement )
2101
2098
2102
2099
@property
2103
2100
def is_bool (self ):
@@ -2344,12 +2341,11 @@ class CategoricalBlock(NonConsolidatableMixIn, ObjectBlock):
2344
2341
_holder = Categorical
2345
2342
_concatenator = staticmethod (_concat ._concat_categorical )
2346
2343
2347
- def __init__ (self , values , placement , fastpath = False , ** kwargs ):
2344
+ def __init__ (self , values , placement , ndim = None ):
2348
2345
2349
2346
# coerce to categorical if we can
2350
2347
super (CategoricalBlock , self ).__init__ (_maybe_to_categorical (values ),
2351
- fastpath = True ,
2352
- placement = placement , ** kwargs )
2348
+ placement = placement , ndim = ndim )
2353
2349
2354
2350
@property
2355
2351
def is_view (self ):
@@ -2466,12 +2462,12 @@ class DatetimeBlock(DatetimeLikeBlockMixin, Block):
2466
2462
is_datetime = True
2467
2463
_can_hold_na = True
2468
2464
2469
- def __init__ (self , values , placement , fastpath = False , ** kwargs ):
2465
+ def __init__ (self , values , placement , ndim = None ):
2470
2466
if values .dtype != _NS_DTYPE :
2471
2467
values = conversion .ensure_datetime64ns (values )
2472
2468
2473
- super (DatetimeBlock , self ).__init__ (values , fastpath = True ,
2474
- placement = placement , ** kwargs )
2469
+ super (DatetimeBlock , self ).__init__ (values ,
2470
+ placement = placement , ndim = ndim )
2475
2471
2476
2472
def _astype (self , dtype , mgr = None , ** kwargs ):
2477
2473
"""
@@ -2602,13 +2598,11 @@ class DatetimeTZBlock(NonConsolidatableMixIn, DatetimeBlock):
2602
2598
_concatenator = staticmethod (_concat ._concat_datetime )
2603
2599
is_datetimetz = True
2604
2600
2605
- def __init__ (self , values , placement , ndim = 2 , ** kwargs ):
2601
+ def __init__ (self , values , placement , ndim = 2 , dtype = None ):
2606
2602
2607
2603
if not isinstance (values , self ._holder ):
2608
2604
values = self ._holder (values )
2609
2605
2610
- dtype = kwargs .pop ('dtype' , None )
2611
-
2612
2606
if dtype is not None :
2613
2607
if isinstance (dtype , compat .string_types ):
2614
2608
dtype = DatetimeTZDtype .construct_from_string (dtype )
@@ -2618,7 +2612,7 @@ def __init__(self, values, placement, ndim=2, **kwargs):
2618
2612
raise ValueError ("cannot create a DatetimeTZBlock without a tz" )
2619
2613
2620
2614
super (DatetimeTZBlock , self ).__init__ (values , placement = placement ,
2621
- ndim = ndim , ** kwargs )
2615
+ ndim = ndim )
2622
2616
2623
2617
def copy (self , deep = True , mgr = None ):
2624
2618
""" copy constructor """
@@ -2824,7 +2818,7 @@ def copy(self, deep=True, mgr=None):
2824
2818
2825
2819
def make_block_same_class (self , values , placement , sparse_index = None ,
2826
2820
kind = None , dtype = None , fill_value = None ,
2827
- copy = False , fastpath = True , ** kwargs ):
2821
+ copy = False , ndim = None ):
2828
2822
""" return a new block """
2829
2823
if dtype is None :
2830
2824
dtype = values .dtype
@@ -2843,8 +2837,7 @@ def make_block_same_class(self, values, placement, sparse_index=None,
2843
2837
# won't take space since there's 0 items, plus it will preserve
2844
2838
# the dtype.
2845
2839
return self .make_block (np .empty (values .shape , dtype = dtype ),
2846
- placement ,
2847
- fastpath = True )
2840
+ placement )
2848
2841
elif nitems > 1 :
2849
2842
raise ValueError ("Only 1-item 2d sparse blocks are supported" )
2850
2843
else :
@@ -2853,7 +2846,7 @@ def make_block_same_class(self, values, placement, sparse_index=None,
2853
2846
new_values = SparseArray (values , sparse_index = sparse_index ,
2854
2847
kind = kind or self .kind , dtype = dtype ,
2855
2848
fill_value = fill_value , copy = copy )
2856
- return self .make_block (new_values , fastpath = fastpath ,
2849
+ return self .make_block (new_values ,
2857
2850
placement = placement )
2858
2851
2859
2852
def interpolate (self , method = 'pad' , axis = 0 , inplace = False , limit = None ,
@@ -2962,16 +2955,20 @@ def get_block_type(values, dtype=None):
2962
2955
2963
2956
2964
2957
def make_block (values , placement , klass = None , ndim = None , dtype = None ,
2965
- fastpath = False ):
2958
+ fastpath = None ):
2959
+ if fastpath is not None :
2960
+ # GH#19265 pyarrow is passing this
2961
+ warnings .warn ("fastpath argument is deprecated, will be removed "
2962
+ "in a future release." , DeprecationWarning )
2966
2963
if klass is None :
2967
2964
dtype = dtype or values .dtype
2968
2965
klass = get_block_type (values , dtype )
2969
2966
2970
2967
elif klass is DatetimeTZBlock and not is_datetimetz (values ):
2971
- return klass (values , ndim = ndim , fastpath = fastpath ,
2968
+ return klass (values , ndim = ndim ,
2972
2969
placement = placement , dtype = dtype )
2973
2970
2974
- return klass (values , ndim = ndim , fastpath = fastpath , placement = placement )
2971
+ return klass (values , ndim = ndim , placement = placement )
2975
2972
2976
2973
# TODO: flexible with index=None and/or items=None
2977
2974
@@ -3031,7 +3028,7 @@ class BlockManager(PandasObject):
3031
3028
__slots__ = ['axes' , 'blocks' , '_ndim' , '_shape' , '_known_consolidated' ,
3032
3029
'_is_consolidated' , '_blknos' , '_blklocs' ]
3033
3030
3034
- def __init__ (self , blocks , axes , do_integrity_check = True , fastpath = True ):
3031
+ def __init__ (self , blocks , axes , do_integrity_check = True ):
3035
3032
self .axes = [_ensure_index (ax ) for ax in axes ]
3036
3033
self .blocks = tuple (blocks )
3037
3034
@@ -3642,8 +3639,7 @@ def get_slice(self, slobj, axis=0):
3642
3639
new_axes = list (self .axes )
3643
3640
new_axes [axis ] = new_axes [axis ][slobj ]
3644
3641
3645
- bm = self .__class__ (new_blocks , new_axes , do_integrity_check = False ,
3646
- fastpath = True )
3642
+ bm = self .__class__ (new_blocks , new_axes , do_integrity_check = False )
3647
3643
bm ._consolidate_inplace ()
3648
3644
return bm
3649
3645
@@ -3798,7 +3794,7 @@ def xs(self, key, axis=1, copy=True, takeable=False):
3798
3794
# we must copy here as we are mixed type
3799
3795
for blk in self .blocks :
3800
3796
newb = make_block (values = blk .values [slicer ],
3801
- klass = blk .__class__ , fastpath = True ,
3797
+ klass = blk .__class__ ,
3802
3798
placement = blk .mgr_locs )
3803
3799
new_blocks .append (newb )
3804
3800
elif len (self .blocks ) == 1 :
@@ -3808,8 +3804,7 @@ def xs(self, key, axis=1, copy=True, takeable=False):
3808
3804
vals = vals .copy ()
3809
3805
new_blocks = [make_block (values = vals ,
3810
3806
placement = block .mgr_locs ,
3811
- klass = block .__class__ ,
3812
- fastpath = True , )]
3807
+ klass = block .__class__ )]
3813
3808
3814
3809
return self .__class__ (new_blocks , new_axes )
3815
3810
@@ -3912,7 +3907,7 @@ def iget(self, i, fastpath=True):
3912
3907
return SingleBlockManager (
3913
3908
[block .make_block_same_class (values ,
3914
3909
placement = slice (0 , len (values )),
3915
- ndim = 1 , fastpath = True )],
3910
+ ndim = 1 )],
3916
3911
self .axes [1 ])
3917
3912
3918
3913
def get_scalar (self , tup ):
@@ -4434,8 +4429,7 @@ def __init__(self, block, axis, do_integrity_check=False, fastpath=False):
4434
4429
block = block [0 ]
4435
4430
4436
4431
if not isinstance (block , Block ):
4437
- block = make_block (block , placement = slice (0 , len (axis )), ndim = 1 ,
4438
- fastpath = True )
4432
+ block = make_block (block , placement = slice (0 , len (axis )), ndim = 1 )
4439
4433
4440
4434
self .blocks = [block ]
4441
4435
@@ -4727,7 +4721,6 @@ def form_blocks(arrays, names, axes):
4727
4721
if len (items_dict ['DatetimeTZBlock' ]):
4728
4722
dttz_blocks = [make_block (array ,
4729
4723
klass = DatetimeTZBlock ,
4730
- fastpath = True ,
4731
4724
placement = [i ])
4732
4725
for i , _ , array in items_dict ['DatetimeTZBlock' ]]
4733
4726
blocks .extend (dttz_blocks )
@@ -4745,8 +4738,7 @@ def form_blocks(arrays, names, axes):
4745
4738
blocks .extend (sparse_blocks )
4746
4739
4747
4740
if len (items_dict ['CategoricalBlock' ]) > 0 :
4748
- cat_blocks = [make_block (array , klass = CategoricalBlock , fastpath = True ,
4749
- placement = [i ])
4741
+ cat_blocks = [make_block (array , klass = CategoricalBlock , placement = [i ])
4750
4742
for i , _ , array in items_dict ['CategoricalBlock' ]]
4751
4743
blocks .extend (cat_blocks )
4752
4744
@@ -4802,8 +4794,7 @@ def _sparse_blockify(tuples, dtype=None):
4802
4794
new_blocks = []
4803
4795
for i , names , array in tuples :
4804
4796
array = _maybe_to_sparse (array )
4805
- block = make_block (array , klass = SparseBlock , fastpath = True ,
4806
- placement = [i ])
4797
+ block = make_block (array , klass = SparseBlock , placement = [i ])
4807
4798
new_blocks .append (block )
4808
4799
4809
4800
return new_blocks
@@ -4887,7 +4878,7 @@ def _merge_blocks(blocks, dtype=None, _can_consolidate=True):
4887
4878
new_values = new_values [argsort ]
4888
4879
new_mgr_locs = new_mgr_locs [argsort ]
4889
4880
4890
- return make_block (new_values , fastpath = True , placement = new_mgr_locs )
4881
+ return make_block (new_values , placement = new_mgr_locs )
4891
4882
4892
4883
# no merge
4893
4884
return blocks
0 commit comments