A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pandas-dev/pandas/issues/51186 below:

de-duplicate iterate_slices · Issue #51186 · pandas-dev/pandas · GitHub

# From DataFrameGroupBy
    def _iterate_slices(self) -> Iterable[Series]:
        obj = self._selected_obj
        if self.axis == 1:
            obj = obj.T

        if isinstance(obj, Series) and obj.name not in self.exclusions:
            # Occurs when doing DataFrameGroupBy(...)["X"]
            yield obj
        else:
            for label, values in obj.items():
                if label in self.exclusions:
                    continue

                yield values

Iterating over self._selected_obj but then excluding self.exclusons seems a lot like just iterating over self._obj_with_exclusions. I checked that using obj_with_exclusions does break things, but didn't figure out why.

it'd be nice if we could simplify this, or at least document why we need a third thing. cc @rhshadrach

If it were just obj_with_exclusions, then in DataFrameGroupBy._indexed_output_to_ndframe we could just use self._obj_with_exclusions.columns instead of re-constructing an Index (i think this re-construction is largely leftover from a time when we dropped nuisance columns)

Expected Behavior

NA

Installed Versions

Replace this line with the output of pd.show_versions()


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4