74
74
ensure_block_shape ,
75
75
extend_blocks ,
76
76
get_block_type ,
77
- make_block ,
77
+ new_block ,
78
78
)
79
79
from pandas .core .internals .ops import (
80
80
blockwise_all ,
@@ -322,7 +322,7 @@ def unpickle_block(values, mgr_locs, ndim: int):
322
322
# TODO(EA2D): ndim would be unnecessary with 2D EAs
323
323
# older pickles may store e.g. DatetimeIndex instead of DatetimeArray
324
324
values = extract_array (values , extract_numpy = True )
325
- return make_block (values , placement = mgr_locs , ndim = ndim )
325
+ return new_block (values , placement = mgr_locs , ndim = ndim )
326
326
327
327
if isinstance (state , tuple ) and len (state ) >= 4 and "0.14.1" in state [3 ]:
328
328
state = state [3 ]["0.14.1" ]
@@ -1148,7 +1148,7 @@ def value_getitem(placement):
1148
1148
# one item.
1149
1149
# TODO(EA2D): special casing unnecessary with 2D EAs
1150
1150
new_blocks .extend (
1151
- make_block (
1151
+ new_block (
1152
1152
values = value ,
1153
1153
ndim = self .ndim ,
1154
1154
placement = slice (mgr_loc , mgr_loc + 1 ),
@@ -1164,7 +1164,7 @@ def value_getitem(placement):
1164
1164
unfit_val_items = unfit_val_locs [0 ].append (unfit_val_locs [1 :])
1165
1165
1166
1166
new_blocks .append (
1167
- make_block (
1167
+ new_block (
1168
1168
values = value_getitem (unfit_val_items ),
1169
1169
ndim = self .ndim ,
1170
1170
placement = unfit_mgr_locs ,
@@ -1209,7 +1209,7 @@ def insert(self, loc: int, item: Hashable, value, allow_duplicates: bool = False
1209
1209
value = ensure_block_shape (value , ndim = 2 )
1210
1210
1211
1211
# TODO: type value as ArrayLike
1212
- block = make_block (values = value , ndim = self .ndim , placement = slice (loc , loc + 1 ))
1212
+ block = new_block (values = value , ndim = self .ndim , placement = slice (loc , loc + 1 ))
1213
1213
1214
1214
for blkno , count in _fast_count_smallints (self .blknos [loc :]):
1215
1215
blk = self .blocks [blkno ]
@@ -1436,7 +1436,7 @@ def _make_na_block(self, placement, fill_value=None):
1436
1436
dtype , fill_value = infer_dtype_from_scalar (fill_value )
1437
1437
block_values = np .empty (block_shape , dtype = dtype )
1438
1438
block_values .fill (fill_value )
1439
- return make_block (block_values , placement = placement , ndim = block_values .ndim )
1439
+ return new_block (block_values , placement = placement , ndim = block_values .ndim )
1440
1440
1441
1441
def take (self , indexer , axis : int = 1 , verify : bool = True , convert : bool = True ):
1442
1442
"""
@@ -1562,7 +1562,7 @@ def from_array(cls, array: ArrayLike, index: Index) -> SingleBlockManager:
1562
1562
"""
1563
1563
Constructor for if we have an array that is not yet a Block.
1564
1564
"""
1565
- block = make_block (array , placement = slice (0 , len (index )), ndim = 1 )
1565
+ block = new_block (array , placement = slice (0 , len (index )), ndim = 1 )
1566
1566
return cls (block , index )
1567
1567
1568
1568
def _post_setstate (self ):
@@ -1669,7 +1669,7 @@ def create_block_manager_from_blocks(blocks, axes: List[Index]) -> BlockManager:
1669
1669
# is basically "all items", but if there're many, don't bother
1670
1670
# converting, it's an error anyway.
1671
1671
blocks = [
1672
- make_block (
1672
+ new_block (
1673
1673
values = blocks [0 ], placement = slice (0 , len (axes [0 ])), ndim = 2
1674
1674
)
1675
1675
]
@@ -1780,7 +1780,7 @@ def _form_blocks(
1780
1780
1781
1781
if len (items_dict ["DatetimeTZBlock" ]):
1782
1782
dttz_blocks = [
1783
- make_block (array , klass = DatetimeTZBlock , placement = i , ndim = 2 )
1783
+ new_block (array , klass = DatetimeTZBlock , placement = i , ndim = 2 )
1784
1784
for i , array in items_dict ["DatetimeTZBlock" ]
1785
1785
]
1786
1786
blocks .extend (dttz_blocks )
@@ -1791,22 +1791,22 @@ def _form_blocks(
1791
1791
1792
1792
if len (items_dict ["CategoricalBlock" ]) > 0 :
1793
1793
cat_blocks = [
1794
- make_block (array , klass = CategoricalBlock , placement = i , ndim = 2 )
1794
+ new_block (array , klass = CategoricalBlock , placement = i , ndim = 2 )
1795
1795
for i , array in items_dict ["CategoricalBlock" ]
1796
1796
]
1797
1797
blocks .extend (cat_blocks )
1798
1798
1799
1799
if len (items_dict ["ExtensionBlock" ]):
1800
1800
external_blocks = [
1801
- make_block (array , klass = ExtensionBlock , placement = i , ndim = 2 )
1801
+ new_block (array , klass = ExtensionBlock , placement = i , ndim = 2 )
1802
1802
for i , array in items_dict ["ExtensionBlock" ]
1803
1803
]
1804
1804
1805
1805
blocks .extend (external_blocks )
1806
1806
1807
1807
if len (items_dict ["ObjectValuesExtensionBlock" ]):
1808
1808
external_blocks = [
1809
- make_block (array , klass = ObjectValuesExtensionBlock , placement = i , ndim = 2 )
1809
+ new_block (array , klass = ObjectValuesExtensionBlock , placement = i , ndim = 2 )
1810
1810
for i , array in items_dict ["ObjectValuesExtensionBlock" ]
1811
1811
]
1812
1812
@@ -1819,7 +1819,7 @@ def _form_blocks(
1819
1819
block_values = np .empty (shape , dtype = object )
1820
1820
block_values .fill (np .nan )
1821
1821
1822
- na_block = make_block (block_values , placement = extra_locs , ndim = 2 )
1822
+ na_block = new_block (block_values , placement = extra_locs , ndim = 2 )
1823
1823
blocks .append (na_block )
1824
1824
1825
1825
return blocks
@@ -1836,7 +1836,7 @@ def _simple_blockify(tuples, dtype) -> List[Block]:
1836
1836
if dtype is not None and values .dtype != dtype : # pragma: no cover
1837
1837
values = values .astype (dtype )
1838
1838
1839
- block = make_block (values , placement = placement , ndim = 2 )
1839
+ block = new_block (values , placement = placement , ndim = 2 )
1840
1840
return [block ]
1841
1841
1842
1842
@@ -1850,7 +1850,7 @@ def _multi_blockify(tuples, dtype: Optional[Dtype] = None):
1850
1850
1851
1851
values , placement = _stack_arrays (list (tup_block ), dtype )
1852
1852
1853
- block = make_block (values , placement = placement , ndim = 2 )
1853
+ block = new_block (values , placement = placement , ndim = 2 )
1854
1854
new_blocks .append (block )
1855
1855
1856
1856
return new_blocks
@@ -1928,7 +1928,7 @@ def _merge_blocks(
1928
1928
new_values = new_values [argsort ]
1929
1929
new_mgr_locs = new_mgr_locs [argsort ]
1930
1930
1931
- return [make_block (new_values , placement = new_mgr_locs , ndim = 2 )]
1931
+ return [new_block (new_values , placement = new_mgr_locs , ndim = 2 )]
1932
1932
1933
1933
# can't consolidate --> no merge
1934
1934
return blocks
0 commit comments