Skip to content

Commit 04edff4

Browse files
committed
REF: starting to refactor for removing LongPanel, GH #108
1 parent 40f4b03 commit 04edff4

File tree

6 files changed

+187
-437
lines changed

6 files changed

+187
-437
lines changed

RELEASE.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,10 @@ Thanks
9898
------
9999
- Craig Austin
100100
- Andreas Hilboll
101-
- Adam Klein
102101
- Matt Harrison
103102
- Mario Gamboa-Cavazos
104103
- Arthur Gerigk
104+
- Adam Klein
105105
- Gregg Lind
106106
- Solomon Negusse
107107
- Wouter Overmeire

pandas/core/api.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from pandas.core.daterange import DateRange
1111
from pandas.core.series import Series, TimeSeries
1212
from pandas.core.frame import DataFrame
13-
from pandas.core.panel import Panel, LongPanel
13+
from pandas.core.panel import Panel
1414
from pandas.core.groupby import groupby
1515
from pandas.core.reshape import pivot_simple as pivot
1616

pandas/core/frame.py

+4-23
Original file line numberDiff line numberDiff line change
@@ -2484,31 +2484,12 @@ def _apply_broadcast(self, func, axis):
24842484

24852485
return result
24862486

2487-
def _apply_level(self, f, axis='major', broadcast=False):
2488-
from pandas.core.panel import LongPanel
2489-
2490-
if axis == 'major':
2491-
panel = self.swapaxes()
2492-
result = panel._apply_level(f, axis='minor', broadcast=broadcast)
2493-
if broadcast:
2494-
result = result.swapaxes()
2495-
2496-
return result
2497-
2498-
bounds = self.index._bounds
2499-
values = self.values
2500-
N, _ = values.shape
2501-
result = group_agg(values, bounds, f)
2502-
2487+
def _apply_level(self, f, level=0, broadcast=False):
2488+
grouped = self.groupby(level=level)
25032489
if broadcast:
2504-
repeater = np.concatenate((np.diff(bounds), [N - bounds[-1]]))
2505-
panel = LongPanel(result.repeat(repeater, axis=0),
2506-
columns=self.items, index=self.index)
2490+
return grouped.transform(f)
25072491
else:
2508-
panel = DataFrame(result, index=self.major_axis,
2509-
columns=self.items)
2510-
2511-
return panel
2492+
return grouped.agg(f)
25122493

25132494
def applymap(self, func):
25142495
"""

0 commit comments

Comments
 (0)