1
1
import warnings
2
-
3
2
import copy
4
3
from warnings import catch_warnings
5
4
import inspect
83
82
from pandas .util ._decorators import cache_readonly
84
83
from pandas .util ._validators import validate_bool_kwarg
85
84
from pandas import compat
86
- from pandas .compat import range , map , zip , u , _default_fill_value
85
+ from pandas .compat import range , map , zip , u
87
86
88
87
89
88
class Block (PandasObject ):
@@ -1889,10 +1888,6 @@ def _holder(self):
1889
1888
# For extension blocks, the holder is values-dependent.
1890
1889
return type (self .values )
1891
1890
1892
- @property
1893
- def fill_value (self ):
1894
- return self .values .dtype .na_value # TODO: change to _na_value
1895
-
1896
1891
@property
1897
1892
def _can_hold_na (self ):
1898
1893
# The default ExtensionArray._can_hold_na is True
@@ -4391,8 +4386,6 @@ def reindex_indexer(self, new_axis, indexer, axis, fill_value=None,
4391
4386
4392
4387
pandas-indexer with -1's only.
4393
4388
"""
4394
- # TODO: see if we can make fill_value be {col -> fill_value}
4395
- # maybe earlier...
4396
4389
if indexer is None :
4397
4390
if new_axis is self .axes [axis ] and not copy :
4398
4391
return self
@@ -4415,17 +4408,9 @@ def reindex_indexer(self, new_axis, indexer, axis, fill_value=None,
4415
4408
new_blocks = self ._slice_take_blocks_ax0 (indexer ,
4416
4409
fill_tuple = (fill_value ,))
4417
4410
else :
4418
- if fill_value is None :
4419
- fill_value = _default_fill_value
4420
-
4421
- new_blocks = []
4422
- for blk in self .blocks :
4423
- if fill_value is not _default_fill_value :
4424
- fill_tuple = (fill_value ,)
4425
- else :
4426
- fill_tuple = (blk .fill_value ,)
4427
- new_blocks = [blk .take_nd (indexer , axis = axis , fill_tuple = fill_tuple )
4428
- for blk in self .blocks ]
4411
+ new_blocks = [blk .take_nd (indexer , axis = axis , fill_tuple = (
4412
+ fill_value if fill_value is not None else blk .fill_value ,))
4413
+ for blk in self .blocks ]
4429
4414
4430
4415
new_axes = list (self .axes )
4431
4416
new_axes [axis ] = new_axis
@@ -4451,9 +4436,6 @@ def _slice_take_blocks_ax0(self, slice_or_indexer, fill_tuple=None):
4451
4436
if self ._is_single_block :
4452
4437
blk = self .blocks [0 ]
4453
4438
4454
- if allow_fill and fill_tuple [0 ] is _default_fill_value :
4455
- fill_tuple = (blk .fill_value ,)
4456
-
4457
4439
if sl_type in ('slice' , 'mask' ):
4458
4440
return [blk .getitem_block (slobj , new_mgr_locs = slice (0 , sllen ))]
4459
4441
elif not allow_fill or self .ndim == 1 :
@@ -5422,25 +5404,6 @@ def concatenate_block_managers(mgrs_indexers, axes, concat_axis, copy):
5422
5404
elif is_uniform_join_units (join_units ):
5423
5405
b = join_units [0 ].block .concat_same_type (
5424
5406
[ju .block for ju in join_units ], placement = placement )
5425
- elif is_uniform_reindexer (join_units ):
5426
- old_block = join_units [0 ].block
5427
-
5428
- new_values = concatenate_join_units (join_units , concat_axis ,
5429
- copy = copy )
5430
- if new_values .ndim == 2 :
5431
- # XXX: categorical returns a categorical here
5432
- # EA returns a 2d ndarray
5433
- # need to harmoinze these to always be EAs?
5434
- assert new_values .shape [0 ] == 1
5435
- new_values = new_values [0 ]
5436
-
5437
- assert isinstance (old_block ._holder , ABCExtensionArray )
5438
-
5439
- b = old_block .make_block_same_class (
5440
- old_block ._holder ._from_sequence (new_values ),
5441
- placement = placement
5442
- )
5443
-
5444
5407
else :
5445
5408
b = make_block (
5446
5409
concatenate_join_units (join_units , concat_axis , copy = copy ),
@@ -5471,13 +5434,6 @@ def is_uniform_join_units(join_units):
5471
5434
len (join_units ) > 1 )
5472
5435
5473
5436
5474
- def is_uniform_reindexer (join_units ):
5475
- # For when we know we can reindex without changing type
5476
- return (
5477
- all (ju .block and ju .block .is_extension for ju in join_units )
5478
- )
5479
-
5480
-
5481
5437
def get_empty_dtype_and_na (join_units ):
5482
5438
"""
5483
5439
Return dtype and N/A values to use when concatenating specified units.
@@ -5505,15 +5461,12 @@ def get_empty_dtype_and_na(join_units):
5505
5461
5506
5462
upcast_classes = defaultdict (list )
5507
5463
null_upcast_classes = defaultdict (list )
5508
-
5509
5464
for dtype , unit in zip (dtypes , join_units ):
5510
5465
if dtype is None :
5511
5466
continue
5512
5467
5513
5468
if is_categorical_dtype (dtype ):
5514
5469
upcast_cls = 'category'
5515
- elif is_extension_array_dtype (dtype ):
5516
- upcast_cls = 'extension'
5517
5470
elif is_datetimetz (dtype ):
5518
5471
upcast_cls = 'datetimetz'
5519
5472
elif issubclass (dtype .type , np .bool_ ):
@@ -5543,8 +5496,6 @@ def get_empty_dtype_and_na(join_units):
5543
5496
# create the result
5544
5497
if 'object' in upcast_classes :
5545
5498
return np .dtype (np .object_ ), np .nan
5546
- elif 'extension' in upcast_classes :
5547
- return np .dtype (np .object_ ), None
5548
5499
elif 'bool' in upcast_classes :
5549
5500
if has_none_blocks :
5550
5501
return np .dtype (np .object_ ), np .nan
@@ -5804,9 +5755,7 @@ def dtype(self):
5804
5755
if self .block is None :
5805
5756
raise AssertionError ("Block is None, no dtype" )
5806
5757
5807
- if not self .needs_filling or self .block .is_extension :
5808
- # ExtensionDtypes by definition can hold their
5809
- # NA value.
5758
+ if not self .needs_filling :
5810
5759
return self .block .dtype
5811
5760
else :
5812
5761
return _get_dtype (maybe_promote (self .block .dtype ,
0 commit comments