Skip to content

Commit 0bb016a

Browse files
committed
REF: starting to refactor for removing LongPanel, GH #108
1 parent b27a074 commit 0bb016a

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
@@ -94,9 +94,9 @@ Thanks
9494
------
9595
- Craig Austin
9696
- Andreas Hilboll
97-
- Adam Klein
9897
- Matt Harrison
9998
- Arthur Gerigk
99+
- Adam Klein
100100
- Gregg Lind
101101
- Solomon Negusse
102102
- 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
@@ -2458,31 +2458,12 @@ def _apply_broadcast(self, func, axis):
24582458

24592459
return result
24602460

2461-
def _apply_level(self, f, axis='major', broadcast=False):
2462-
from pandas.core.panel import LongPanel
2463-
2464-
if axis == 'major':
2465-
panel = self.swapaxes()
2466-
result = panel._apply_level(f, axis='minor', broadcast=broadcast)
2467-
if broadcast:
2468-
result = result.swapaxes()
2469-
2470-
return result
2471-
2472-
bounds = self.index._bounds
2473-
values = self.values
2474-
N, _ = values.shape
2475-
result = group_agg(values, bounds, f)
2476-
2461+
def _apply_level(self, f, level=0, broadcast=False):
2462+
grouped = self.groupby(level=level)
24772463
if broadcast:
2478-
repeater = np.concatenate((np.diff(bounds), [N - bounds[-1]]))
2479-
panel = LongPanel(result.repeat(repeater, axis=0),
2480-
columns=self.items, index=self.index)
2464+
return grouped.transform(f)
24812465
else:
2482-
panel = DataFrame(result, index=self.major_axis,
2483-
columns=self.items)
2484-
2485-
return panel
2466+
return grouped.agg(f)
24862467

24872468
def applymap(self, func):
24882469
"""

0 commit comments

Comments
 (0)