Skip to content

Commit 61d6fae

Browse files
jbrockmendelPingviinituutti
authored andcommitted
DEPR: remove tm.makePanel and all usages (pandas-dev#25231)
1 parent 9a8a331 commit 61d6fae

File tree

8 files changed

+20
-1630
lines changed

8 files changed

+20
-1630
lines changed

pandas/tests/frame/test_reshape.py

-9
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
from datetime import datetime
66
import itertools
7-
from warnings import catch_warnings, simplefilter
87

98
import numpy as np
109
import pytest
@@ -49,14 +48,6 @@ def test_pivot(self):
4948
assert pivoted.index.name == 'index'
5049
assert pivoted.columns.names == (None, 'columns')
5150

52-
with catch_warnings(record=True):
53-
# pivot multiple columns
54-
simplefilter("ignore", FutureWarning)
55-
wp = tm.makePanel()
56-
lp = wp.to_frame()
57-
df = lp.reset_index()
58-
tm.assert_frame_equal(df.pivot('major', 'minor'), lp.unstack())
59-
6051
def test_pivot_duplicates(self):
6152
data = DataFrame({'a': ['bar', 'bar', 'foo', 'foo', 'foo'],
6253
'b': ['one', 'two', 'one', 'one', 'two'],

pandas/tests/generic/test_generic.py

+1-51
Original file line numberDiff line numberDiff line change
@@ -740,23 +740,11 @@ def test_squeeze(self):
740740
tm.assert_series_equal(s.squeeze(), s)
741741
for df in [tm.makeTimeDataFrame()]:
742742
tm.assert_frame_equal(df.squeeze(), df)
743-
with catch_warnings(record=True):
744-
simplefilter("ignore", FutureWarning)
745-
for p in [tm.makePanel()]:
746-
tm.assert_panel_equal(p.squeeze(), p)
747743

748744
# squeezing
749745
df = tm.makeTimeDataFrame().reindex(columns=['A'])
750746
tm.assert_series_equal(df.squeeze(), df['A'])
751747

752-
with catch_warnings(record=True):
753-
simplefilter("ignore", FutureWarning)
754-
p = tm.makePanel().reindex(items=['ItemA'])
755-
tm.assert_frame_equal(p.squeeze(), p['ItemA'])
756-
757-
p = tm.makePanel().reindex(items=['ItemA'], minor_axis=['A'])
758-
tm.assert_series_equal(p.squeeze(), p.loc['ItemA', :, 'A'])
759-
760748
# don't fail with 0 length dimensions GH11229 & GH8999
761749
empty_series = Series([], name='five')
762750
empty_frame = DataFrame([empty_series])
@@ -789,23 +777,13 @@ def test_numpy_squeeze(self):
789777
tm.assert_series_equal(np.squeeze(df), df['A'])
790778

791779
def test_transpose(self):
792-
msg = (r"transpose\(\) got multiple values for "
793-
r"keyword argument 'axes'")
794780
for s in [tm.makeFloatSeries(), tm.makeStringSeries(),
795781
tm.makeObjectSeries()]:
796782
# calls implementation in pandas/core/base.py
797783
tm.assert_series_equal(s.transpose(), s)
798784
for df in [tm.makeTimeDataFrame()]:
799785
tm.assert_frame_equal(df.transpose().transpose(), df)
800786

801-
with catch_warnings(record=True):
802-
simplefilter("ignore", FutureWarning)
803-
for p in [tm.makePanel()]:
804-
tm.assert_panel_equal(p.transpose(2, 0, 1)
805-
.transpose(1, 2, 0), p)
806-
with pytest.raises(TypeError, match=msg):
807-
p.transpose(2, 0, 1, axes=(2, 0, 1))
808-
809787
def test_numpy_transpose(self):
810788
msg = "the 'axes' parameter is not supported"
811789

@@ -821,13 +799,6 @@ def test_numpy_transpose(self):
821799
with pytest.raises(ValueError, match=msg):
822800
np.transpose(df, axes=1)
823801

824-
with catch_warnings(record=True):
825-
simplefilter("ignore", FutureWarning)
826-
p = tm.makePanel()
827-
tm.assert_panel_equal(np.transpose(
828-
np.transpose(p, axes=(2, 0, 1)),
829-
axes=(1, 2, 0)), p)
830-
831802
def test_take(self):
832803
indices = [1, 5, -2, 6, 3, -1]
833804
for s in [tm.makeFloatSeries(), tm.makeStringSeries(),
@@ -843,27 +814,12 @@ def test_take(self):
843814
columns=df.columns)
844815
tm.assert_frame_equal(out, expected)
845816

846-
indices = [-3, 2, 0, 1]
847-
with catch_warnings(record=True):
848-
simplefilter("ignore", FutureWarning)
849-
for p in [tm.makePanel()]:
850-
out = p.take(indices)
851-
expected = Panel(data=p.values.take(indices, axis=0),
852-
items=p.items.take(indices),
853-
major_axis=p.major_axis,
854-
minor_axis=p.minor_axis)
855-
tm.assert_panel_equal(out, expected)
856-
857817
def test_take_invalid_kwargs(self):
858818
indices = [-3, 2, 0, 1]
859819
s = tm.makeFloatSeries()
860820
df = tm.makeTimeDataFrame()
861821

862-
with catch_warnings(record=True):
863-
simplefilter("ignore", FutureWarning)
864-
p = tm.makePanel()
865-
866-
for obj in (s, df, p):
822+
for obj in (s, df):
867823
msg = r"take\(\) got an unexpected keyword argument 'foo'"
868824
with pytest.raises(TypeError, match=msg):
869825
obj.take(indices, foo=2)
@@ -966,12 +922,6 @@ def test_equals(self):
966922
assert a.equals(e)
967923
assert e.equals(f)
968924

969-
def test_describe_raises(self):
970-
with catch_warnings(record=True):
971-
simplefilter("ignore", FutureWarning)
972-
with pytest.raises(NotImplementedError):
973-
tm.makePanel().describe()
974-
975925
def test_pipe(self):
976926
df = DataFrame({'A': [1, 2, 3]})
977927
f = lambda x, y: x ** y

pandas/tests/generic/test_panel.py

+1-22
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,8 @@
33

44
from warnings import catch_warnings, simplefilter
55

6-
import pandas.util._test_decorators as td
7-
86
from pandas import Panel
9-
import pandas.util.testing as tm
10-
from pandas.util.testing import assert_almost_equal, assert_panel_equal
7+
from pandas.util.testing import assert_panel_equal
118

129
from .test_generic import Generic
1310

@@ -16,24 +13,6 @@ class TestPanel(Generic):
1613
_typ = Panel
1714
_comparator = lambda self, x, y: assert_panel_equal(x, y, by_blocks=True)
1815

19-
@td.skip_if_no('xarray', min_version='0.7.0')
20-
def test_to_xarray(self):
21-
from xarray import DataArray
22-
23-
with catch_warnings(record=True):
24-
simplefilter("ignore", FutureWarning)
25-
p = tm.makePanel()
26-
27-
result = p.to_xarray()
28-
assert isinstance(result, DataArray)
29-
assert len(result.coords) == 3
30-
assert_almost_equal(list(result.coords.keys()),
31-
['items', 'major_axis', 'minor_axis'])
32-
assert len(result.dims) == 3
33-
34-
# idempotency
35-
assert_panel_equal(result.to_pandas(), p)
36-
3716

3817
# run all the tests, but wrap each in a warning catcher
3918
for t in ['test_rename', 'test_get_numeric_data',

pandas/tests/indexing/test_panel.py

-22
Original file line numberDiff line numberDiff line change
@@ -122,28 +122,6 @@ def test_panel_getitem(self):
122122
test1 = panel.loc[:, "2002"]
123123
tm.assert_panel_equal(test1, test2)
124124

125-
# GH8710
126-
# multi-element getting with a list
127-
panel = tm.makePanel()
128-
129-
expected = panel.iloc[[0, 1]]
130-
131-
result = panel.loc[['ItemA', 'ItemB']]
132-
tm.assert_panel_equal(result, expected)
133-
134-
result = panel.loc[['ItemA', 'ItemB'], :, :]
135-
tm.assert_panel_equal(result, expected)
136-
137-
result = panel[['ItemA', 'ItemB']]
138-
tm.assert_panel_equal(result, expected)
139-
140-
result = panel.loc['ItemA':'ItemB']
141-
tm.assert_panel_equal(result, expected)
142-
143-
with catch_warnings(record=True):
144-
result = panel.ix[['ItemA', 'ItemB']]
145-
tm.assert_panel_equal(result, expected)
146-
147125
# with an object-like
148126
# GH 9140
149127
class TestObject(object):

pandas/tests/io/test_sql.py

-6
Original file line numberDiff line numberDiff line change
@@ -605,12 +605,6 @@ def test_to_sql_series(self):
605605
s2 = sql.read_sql_query("SELECT * FROM test_series", self.conn)
606606
tm.assert_frame_equal(s.to_frame(), s2)
607607

608-
@pytest.mark.filterwarnings("ignore:\\nPanel:FutureWarning")
609-
def test_to_sql_panel(self):
610-
panel = tm.makePanel()
611-
pytest.raises(NotImplementedError, sql.to_sql, panel,
612-
'test_panel', self.conn)
613-
614608
def test_roundtrip(self):
615609
sql.to_sql(self.test_frame1, 'test_frame_roundtrip',
616610
con=self.conn)

pandas/tests/reshape/test_reshape.py

+12-7
Original file line numberDiff line numberDiff line change
@@ -580,23 +580,28 @@ def test_get_dummies_duplicate_columns(self, df):
580580

581581
class TestCategoricalReshape(object):
582582

583-
@pytest.mark.filterwarnings("ignore:\\nPanel:FutureWarning")
584-
def test_reshaping_panel_categorical(self):
583+
def test_reshaping_multi_index_categorical(self):
585584

586-
p = tm.makePanel()
587-
p['str'] = 'foo'
588-
df = p.to_frame()
585+
# construct a MultiIndexed DataFrame formerly created
586+
# via `tm.makePanel().to_frame()`
587+
cols = ['ItemA', 'ItemB', 'ItemC']
588+
data = {c: tm.makeTimeDataFrame() for c in cols}
589+
df = pd.concat({c: data[c].stack() for c in data}, axis='columns')
590+
df.index.names = ['major', 'minor']
591+
df['str'] = 'foo'
592+
593+
dti = df.index.levels[0]
589594

590595
df['category'] = df['str'].astype('category')
591596
result = df['category'].unstack()
592597

593-
c = Categorical(['foo'] * len(p.major_axis))
598+
c = Categorical(['foo'] * len(dti))
594599
expected = DataFrame({'A': c.copy(),
595600
'B': c.copy(),
596601
'C': c.copy(),
597602
'D': c.copy()},
598603
columns=Index(list('ABCD'), name='minor'),
599-
index=p.major_axis.set_names('major'))
604+
index=dti)
600605
tm.assert_frame_equal(result, expected)
601606

602607

0 commit comments

Comments
 (0)