@@ -1698,7 +1698,7 @@ def construction_error(tot_items, block_shape, axes, e=None):
1698
1698
# -----------------------------------------------------------------------
1699
1699
1700
1700
1701
- def _form_blocks (arrays , names : Index , axes ) -> List [Block ]:
1701
+ def _form_blocks (arrays , names : Index , axes : List [ Index ] ) -> List [Block ]:
1702
1702
# put "leftover" items in float bucket, where else?
1703
1703
# generalize?
1704
1704
items_dict : DefaultDict [str , List ] = defaultdict (list )
@@ -1716,11 +1716,10 @@ def _form_blocks(arrays, names: Index, axes) -> List[Block]:
1716
1716
extra_locs .append (i )
1717
1717
continue
1718
1718
1719
- k = names [name_idx ]
1720
1719
v = arrays [name_idx ]
1721
1720
1722
1721
block_type = get_block_type (v )
1723
- items_dict [block_type .__name__ ].append ((i , k , v ))
1722
+ items_dict [block_type .__name__ ].append ((i , v ))
1724
1723
1725
1724
blocks : List [Block ] = []
1726
1725
if len (items_dict ["FloatBlock" ]):
@@ -1742,7 +1741,7 @@ def _form_blocks(arrays, names: Index, axes) -> List[Block]:
1742
1741
if len (items_dict ["DatetimeTZBlock" ]):
1743
1742
dttz_blocks = [
1744
1743
make_block (array , klass = DatetimeTZBlock , placement = i , ndim = 2 )
1745
- for i , _ , array in items_dict ["DatetimeTZBlock" ]
1744
+ for i , array in items_dict ["DatetimeTZBlock" ]
1746
1745
]
1747
1746
blocks .extend (dttz_blocks )
1748
1747
@@ -1753,22 +1752,22 @@ def _form_blocks(arrays, names: Index, axes) -> List[Block]:
1753
1752
if len (items_dict ["CategoricalBlock" ]) > 0 :
1754
1753
cat_blocks = [
1755
1754
make_block (array , klass = CategoricalBlock , placement = i , ndim = 2 )
1756
- for i , _ , array in items_dict ["CategoricalBlock" ]
1755
+ for i , array in items_dict ["CategoricalBlock" ]
1757
1756
]
1758
1757
blocks .extend (cat_blocks )
1759
1758
1760
1759
if len (items_dict ["ExtensionBlock" ]):
1761
1760
external_blocks = [
1762
1761
make_block (array , klass = ExtensionBlock , placement = i , ndim = 2 )
1763
- for i , _ , array in items_dict ["ExtensionBlock" ]
1762
+ for i , array in items_dict ["ExtensionBlock" ]
1764
1763
]
1765
1764
1766
1765
blocks .extend (external_blocks )
1767
1766
1768
1767
if len (items_dict ["ObjectValuesExtensionBlock" ]):
1769
1768
external_blocks = [
1770
1769
make_block (array , klass = ObjectValuesExtensionBlock , placement = i , ndim = 2 )
1771
- for i , _ , array in items_dict ["ObjectValuesExtensionBlock" ]
1770
+ for i , array in items_dict ["ObjectValuesExtensionBlock" ]
1772
1771
]
1773
1772
1774
1773
blocks .extend (external_blocks )
@@ -1804,7 +1803,7 @@ def _simple_blockify(tuples, dtype) -> List[Block]:
1804
1803
def _multi_blockify (tuples , dtype : Optional [Dtype ] = None ):
1805
1804
""" return an array of blocks that potentially have different dtypes """
1806
1805
# group by dtype
1807
- grouper = itertools .groupby (tuples , lambda x : x [2 ].dtype )
1806
+ grouper = itertools .groupby (tuples , lambda x : x [1 ].dtype )
1808
1807
1809
1808
new_blocks = []
1810
1809
for dtype , tup_block in grouper :
@@ -1817,7 +1816,7 @@ def _multi_blockify(tuples, dtype: Optional[Dtype] = None):
1817
1816
return new_blocks
1818
1817
1819
1818
1820
- def _stack_arrays (tuples , dtype ):
1819
+ def _stack_arrays (tuples , dtype : np . dtype ):
1821
1820
1822
1821
# fml
1823
1822
def _asarray_compat (x ):
@@ -1826,16 +1825,10 @@ def _asarray_compat(x):
1826
1825
else :
1827
1826
return np .asarray (x )
1828
1827
1829
- def _shape_compat (x ) -> Shape :
1830
- if isinstance (x , ABCSeries ):
1831
- return (len (x ),)
1832
- else :
1833
- return x .shape
1834
-
1835
- placement , names , arrays = zip (* tuples )
1828
+ placement , arrays = zip (* tuples )
1836
1829
1837
1830
first = arrays [0 ]
1838
- shape = (len (arrays ),) + _shape_compat ( first )
1831
+ shape = (len (arrays ),) + first . shape
1839
1832
1840
1833
stacked = np .empty (shape , dtype = dtype )
1841
1834
for i , arr in enumerate (arrays ):
0 commit comments