Skip to content

Commit

Permalink
optimize BlockManager.column_arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
jorisvandenbossche committed Apr 21, 2021
1 parent 3b7e2a1 commit 3c9aa99
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pandas/core/internals/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1139,7 +1139,16 @@ def iget_values(self, i: int) -> ArrayLike:

@property
def column_arrays(self) -> list[ArrayLike]:
return [self.iget_values(i) for i in range(len(self.items))]
arrays = [np.asarray(arr) for arr in self.arrays]
result = []
for i in range(len(self.items)):
arr = arrays[self.blknos[i]]
if arr.ndim == 2:
values = arr[self.blklocs[i]]
else:
values = arr
result.append(values)
return result

def iset(self, loc: int | slice | np.ndarray, value: ArrayLike):
"""
Expand Down

0 comments on commit 3c9aa99

Please sign in to comment.