Skip to content
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

REF: remove block access in groupby libreduction Series(Bin)Grouper #40199

Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 1 addition & 3 deletions pandas/_libs/reduction.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@ cdef class _BaseGrouper:
object.__setattr__(cached_ityp, '_index_data', islider.buf)
cached_ityp._engine.clear_mapping()
cached_ityp._cache.clear() # e.g. inferred_freq must go
object.__setattr__(cached_typ._mgr._block, 'values', vslider.buf)
object.__setattr__(cached_typ._mgr._block, 'mgr_locs',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might get a small boost by setting _mgr_locs to BlockPlacement(slice(...)) instead of going through the mgr_locs property

slice(len(vslider.buf)))
cached_typ._mgr.set_values(vslider.buf)
object.__setattr__(cached_typ, '_index', cached_ityp)
object.__setattr__(cached_typ, 'name', self.name)

Expand Down
1 change: 1 addition & 0 deletions pandas/core/internals/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1654,6 +1654,7 @@ def set_values(self, values: ArrayLike):
valid for the current Block/SingleBlockManager (length, dtype, etc).
"""
self.blocks[0].values = values
self.blocks[0].mgr_locs = slice(len(values))


# --------------------------------------------------------------------
Expand Down