BUG: NonConsolidatebleBlock with ndim 1 'take_nd' with len 1 gives wrong ndim #27785
Labels
Bug
ExtensionArray
Extending pandas with custom dtypes or arrays.
Internals
Related to non-user accessible pandas implementation
Milestone
When doing an indexing operation on an EA column that results in a single row, the resulting SingleBlockManager / Block has an inconsistent internal state:
So
df.loc[[0], 'a']
gives a Series as result that holds a 2d block, which leads to other bugs (although not directly visible in the repr. Example: geopandas/geopandas#1078)The reason for this is that
Block.take_nd
does not specify the ndim of the resulting new Block, and thus this is inferred in theNonConsolidatableBlock.__init__
:pandas/pandas/core/internals/blocks.py
Lines 1593 to 1598 in 640d9e1
But, this
len(placement)
is not only 1 in case of a 2D block, but also if you have a 1D block with values of len 1 ...This bug shows with any EA, so also eg Categorical. And it seems to go back to pandas 0.23, and still manifests on master.
The text was updated successfully, but these errors were encountered: