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

CLN: remove _from_mgr (no longer used after GH-45363) #45415

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
16 changes: 0 additions & 16 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,22 +285,6 @@ def _init_mgr(
mgr = mgr.astype(dtype=dtype)
return mgr

@classmethod
def _from_mgr(cls, mgr: Manager):
Copy link
Member Author

Choose a reason for hiding this comment

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

Removed this, because it was only used in the groupby Splitter (and so that usage was removed in the previous PR)

"""
Fastpath to create a new DataFrame/Series from just a BlockManager/ArrayManager.

Notes
-----
Skips setting `_flags` attribute; caller is responsible for doing so.
"""
obj = cls.__new__(cls)
object.__setattr__(obj, "_is_copy", None)
object.__setattr__(obj, "_mgr", mgr)
object.__setattr__(obj, "_item_cache", {})
object.__setattr__(obj, "_attrs", {})
return obj

def _as_manager(self: NDFrameT, typ: str, copy: bool_t = True) -> NDFrameT:
"""
Private helper function to create a DataFrame with specific manager.
Expand Down
15 changes: 5 additions & 10 deletions pandas/core/groupby/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -705,17 +705,14 @@ def get_iterator(
"""
splitter = self._get_splitter(data, axis=axis)
keys = self.group_keys_seq
for key, group in zip(keys, splitter):
yield key, group.__finalize__(data, method="groupby")
yield from zip(keys, splitter)

@final
def _get_splitter(self, data: NDFrame, axis: int = 0) -> DataSplitter:
"""
Returns
-------
Generator yielding subsetted objects

__finalize__ has not been called for the subsetted objects returned.
"""
ids, _, ngroups = self.group_info
return get_splitter(data, ids, ngroups, axis=axis)
Expand Down Expand Up @@ -753,7 +750,6 @@ def apply(
zipped = zip(group_keys, splitter)

for key, group in zipped:
group = group.__finalize__(data, method="groupby")
object.__setattr__(group, "name", key)

# group might be modified
Expand Down Expand Up @@ -1001,7 +997,6 @@ def _aggregate_series_pure_python(
splitter = get_splitter(obj, ids, ngroups, axis=0)

for i, group in enumerate(splitter):
group = group.__finalize__(obj, method="groupby")
res = func(group)
res = libreduction.extract_result(res)

Expand Down Expand Up @@ -1244,8 +1239,9 @@ class SeriesSplitter(DataSplitter):
def _chop(self, sdata: Series, slice_obj: slice) -> Series:
# fastpath equivalent to `sdata.iloc[slice_obj]`
mgr = sdata._mgr.get_slice(slice_obj)
# __finalize__ not called here, must be applied by caller if applicable
return sdata._constructor(mgr, name=sdata.name, fastpath=True)
return sdata._constructor(mgr, name=sdata.name, fastpath=True).__finalize__(
sdata, method="groupby"
)


class FrameSplitter(DataSplitter):
Expand All @@ -1256,8 +1252,7 @@ def _chop(self, sdata: DataFrame, slice_obj: slice) -> DataFrame:
# else:
# return sdata.iloc[:, slice_obj]
mgr = sdata._mgr.get_slice(slice_obj, axis=1 - self.axis)
# __finalize__ not called here, must be applied by caller if applicable
return sdata._constructor(mgr)
return sdata._constructor(mgr).__finalize__(sdata, method="groupby")


def get_splitter(
Expand Down