Skip to content

REF: remove internal Block usage from FrameColumnApply #40166

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions pandas/core/apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -883,9 +883,8 @@ def series_generator(self):
# of it. Kids: don't do this at home.
ser = self.obj._ixs(0, axis=0)
mgr = ser._mgr
blk = mgr.blocks[0]

if is_extension_array_dtype(blk.dtype):
if is_extension_array_dtype(ser.dtype):
# values will be incorrect for this block
# TODO(EA2D): special case would be unnecessary with 2D EAs
obj = self.obj
Expand All @@ -896,7 +895,7 @@ def series_generator(self):
for (arr, name) in zip(values, self.index):
# GH#35462 re-pin mgr in case setitem changed it
ser._mgr = mgr
blk.values = arr
mgr.set_values(arr)
ser.name = name
yield ser

Expand Down
9 changes: 9 additions & 0 deletions pandas/core/internals/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1646,6 +1646,15 @@ def fast_xs(self, loc):
"""
raise NotImplementedError("Use series._values[loc] instead")

def set_values(self, values: ArrayLike):
"""
Set the values of the single block in place.

Use at your own risk! This does not check if the passed values are
valid for the current Block/SingleBlockManager (length, dtype, etc).
"""
self.blocks[0].values = values


# --------------------------------------------------------------------
# Constructor Helpers
Expand Down