|
1 | 1 | """
|
2 |
| -Define the SeriesGroupBy, DataFrameGroupBy, and PanelGroupBy |
| 2 | +Define the SeriesGroupBy and DataFrameGroupBy |
3 | 3 | classes that hold the groupby interfaces (and some implementations).
|
4 | 4 |
|
5 | 5 | These are user facing as the result of the ``df.groupby(...)`` operations,
|
|
39 | 39 | from pandas.core.index import CategoricalIndex, Index, MultiIndex
|
40 | 40 | import pandas.core.indexes.base as ibase
|
41 | 41 | from pandas.core.internals import BlockManager, make_block
|
42 |
| -from pandas.core.panel import Panel |
43 | 42 | from pandas.core.series import Series
|
44 | 43 |
|
45 | 44 | from pandas.plotting._core import boxplot_frame_groupby
|
@@ -1586,90 +1585,3 @@ def groupby_series(obj, col=None):
|
1586 | 1585 | return results
|
1587 | 1586 |
|
1588 | 1587 | boxplot = boxplot_frame_groupby
|
1589 |
| - |
1590 |
| - |
1591 |
| -class PanelGroupBy(NDFrameGroupBy): |
1592 |
| - |
1593 |
| - def aggregate(self, arg, *args, **kwargs): |
1594 |
| - return super(PanelGroupBy, self).aggregate(arg, *args, **kwargs) |
1595 |
| - |
1596 |
| - agg = aggregate |
1597 |
| - |
1598 |
| - def _iterate_slices(self): |
1599 |
| - if self.axis == 0: |
1600 |
| - # kludge |
1601 |
| - if self._selection is None: |
1602 |
| - slice_axis = self._selected_obj.items |
1603 |
| - else: |
1604 |
| - slice_axis = self._selection_list |
1605 |
| - slicer = lambda x: self._selected_obj[x] |
1606 |
| - else: |
1607 |
| - raise NotImplementedError("axis other than 0 is not supported") |
1608 |
| - |
1609 |
| - for val in slice_axis: |
1610 |
| - if val in self.exclusions: |
1611 |
| - continue |
1612 |
| - |
1613 |
| - yield val, slicer(val) |
1614 |
| - |
1615 |
| - def aggregate(self, arg, *args, **kwargs): |
1616 |
| - """ |
1617 |
| - Aggregate using input function or dict of {column -> function} |
1618 |
| -
|
1619 |
| - Parameters |
1620 |
| - ---------- |
1621 |
| - arg : function or dict |
1622 |
| - Function to use for aggregating groups. If a function, must either |
1623 |
| - work when passed a Panel or when passed to Panel.apply. If |
1624 |
| - pass a dict, the keys must be DataFrame column names |
1625 |
| -
|
1626 |
| - Returns |
1627 |
| - ------- |
1628 |
| - aggregated : Panel |
1629 |
| - """ |
1630 |
| - if isinstance(arg, compat.string_types): |
1631 |
| - return getattr(self, arg)(*args, **kwargs) |
1632 |
| - |
1633 |
| - return self._aggregate_generic(arg, *args, **kwargs) |
1634 |
| - |
1635 |
| - def _wrap_generic_output(self, result, obj): |
1636 |
| - if self.axis == 0: |
1637 |
| - new_axes = list(obj.axes) |
1638 |
| - new_axes[0] = self.grouper.result_index |
1639 |
| - elif self.axis == 1: |
1640 |
| - x, y, z = obj.axes |
1641 |
| - new_axes = [self.grouper.result_index, z, x] |
1642 |
| - else: |
1643 |
| - x, y, z = obj.axes |
1644 |
| - new_axes = [self.grouper.result_index, y, x] |
1645 |
| - |
1646 |
| - result = Panel._from_axes(result, new_axes) |
1647 |
| - |
1648 |
| - if self.axis == 1: |
1649 |
| - result = result.swapaxes(0, 1).swapaxes(0, 2) |
1650 |
| - elif self.axis == 2: |
1651 |
| - result = result.swapaxes(0, 2) |
1652 |
| - |
1653 |
| - return result |
1654 |
| - |
1655 |
| - def _aggregate_item_by_item(self, func, *args, **kwargs): |
1656 |
| - obj = self._obj_with_exclusions |
1657 |
| - result = {} |
1658 |
| - |
1659 |
| - if self.axis > 0: |
1660 |
| - for item in obj: |
1661 |
| - try: |
1662 |
| - itemg = DataFrameGroupBy(obj[item], |
1663 |
| - axis=self.axis - 1, |
1664 |
| - grouper=self.grouper) |
1665 |
| - result[item] = itemg.aggregate(func, *args, **kwargs) |
1666 |
| - except (ValueError, TypeError): |
1667 |
| - raise |
1668 |
| - new_axes = list(obj.axes) |
1669 |
| - new_axes[self.axis] = self.grouper.result_index |
1670 |
| - return Panel._from_axes(result, new_axes) |
1671 |
| - else: |
1672 |
| - raise ValueError("axis value must be greater than 0") |
1673 |
| - |
1674 |
| - def _wrap_aggregated_output(self, output, names=None): |
1675 |
| - raise AbstractMethodError(self) |
0 commit comments