Skip to content

Commit 4a30fa5

Browse files
WillAydjreback
authored andcommitted
Remove Panel References from Tests (#26332)
1 parent 6b51c94 commit 4a30fa5

File tree

4 files changed

+15
-20
lines changed

4 files changed

+15
-20
lines changed

pandas/tests/groupby/test_groupby.py

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from collections import OrderedDict, defaultdict
1+
from collections import OrderedDict
22
from datetime import datetime
33
from decimal import Decimal
44
from io import StringIO
@@ -10,7 +10,7 @@
1010

1111
import pandas as pd
1212
from pandas import (
13-
DataFrame, Index, MultiIndex, Panel, Series, Timestamp, date_range,
13+
DataFrame, Index, MultiIndex, Series, Timestamp, date_range,
1414
read_csv)
1515
import pandas.core.common as com
1616
import pandas.util.testing as tm
@@ -509,30 +509,30 @@ def test_frame_multi_key_function_list():
509509

510510

511511
@pytest.mark.parametrize('op', [lambda x: x.sum(), lambda x: x.mean()])
512-
@pytest.mark.filterwarnings("ignore:\\nPanel:FutureWarning")
513512
def test_groupby_multiple_columns(df, op):
514513
data = df
515514
grouped = data.groupby(['A', 'B'])
516515

517516
result1 = op(grouped)
518517

519-
expected = defaultdict(dict)
518+
keys = []
519+
values = []
520520
for n1, gp1 in data.groupby('A'):
521521
for n2, gp2 in gp1.groupby('B'):
522-
expected[n1][n2] = op(gp2.loc[:, ['C', 'D']])
523-
expected = {k: DataFrame(v)
524-
for k, v in expected.items()}
525-
expected = Panel.fromDict(expected).swapaxes(0, 1)
526-
expected.major_axis.name, expected.minor_axis.name = 'A', 'B'
522+
keys.append((n1, n2))
523+
values.append(op(gp2.loc[:, ['C', 'D']]))
524+
525+
mi = MultiIndex.from_tuples(keys, names=['A', 'B'])
526+
expected = pd.concat(values, axis=1).T
527+
expected.index = mi
527528

528529
# a little bit crude
529530
for col in ['C', 'D']:
530531
result_col = op(grouped[col])
532+
pivoted = result1[col]
531533
exp = expected[col]
532-
pivoted = result1[col].unstack()
533-
pivoted2 = result_col.unstack()
534-
assert_frame_equal(pivoted.reindex_like(exp), exp)
535-
assert_frame_equal(pivoted2.reindex_like(exp), exp)
534+
assert_series_equal(result_col, exp)
535+
assert_series_equal(pivoted, exp)
536536

537537
# test single series works the same
538538
result = data['C'].groupby([data['A'], data['B']]).mean()

pandas/tests/io/test_excel.py

-1
Original file line numberDiff line numberDiff line change
@@ -2350,7 +2350,6 @@ def test_ExcelWriter_dispatch_raises(self):
23502350
with pytest.raises(ValueError, match='No engine'):
23512351
ExcelWriter('nothing')
23522352

2353-
@pytest.mark.filterwarnings("ignore:\\nPanel:FutureWarning")
23542353
def test_register_writer(self):
23552354
# some awkward mocking to test out dispatch and such actually works
23562355
called_save = []

pandas/tests/reshape/test_reshape.py

-2
Original file line numberDiff line numberDiff line change
@@ -587,8 +587,6 @@ class TestCategoricalReshape:
587587

588588
def test_reshaping_multi_index_categorical(self):
589589

590-
# construct a MultiIndexed DataFrame formerly created
591-
# via `tm.makePanel().to_frame()`
592590
cols = ['ItemA', 'ItemB', 'ItemC']
593591
data = {c: tm.makeTimeDataFrame() for c in cols}
594592
df = pd.concat({c: data[c].stack() for c in data}, axis='columns')

pandas/tests/sparse/frame/test_frame.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from pandas.errors import PerformanceWarning
1010

1111
import pandas as pd
12-
from pandas import DataFrame, Panel, Series, bdate_range, compat
12+
from pandas import DataFrame, Series, bdate_range, compat
1313
from pandas.core.indexes.datetimes import DatetimeIndex
1414
from pandas.core.sparse import frame as spf
1515
from pandas.core.sparse.api import (
@@ -1053,14 +1053,12 @@ def _check(frame, orig):
10531053
_check(float_frame_fill0, float_frame_fill0_dense)
10541054
_check(float_frame_fill2, float_frame_fill2_dense)
10551055

1056-
@pytest.mark.filterwarnings("ignore:\\nPanel:FutureWarning")
10571056
def test_stack_sparse_frame(self, float_frame, float_frame_int_kind,
10581057
float_frame_fill0, float_frame_fill2):
10591058
def _check(frame):
10601059
dense_frame = frame.to_dense() # noqa
10611060

1062-
wp = Panel.from_dict({'foo': frame})
1063-
from_dense_lp = wp.to_frame()
1061+
from_dense_lp = frame.stack().to_frame()
10641062

10651063
from_sparse_lp = spf.stack_sparse_frame(frame)
10661064

0 commit comments

Comments
 (0)