Skip to content

Remove Panel References from Tests #26332

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions pandas/tests/groupby/test_groupby.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from collections import OrderedDict, defaultdict
from collections import OrderedDict
from datetime import datetime
from decimal import Decimal
from io import StringIO
Expand All @@ -11,7 +11,7 @@

import pandas as pd
from pandas import (
DataFrame, Index, MultiIndex, Panel, Series, Timestamp, date_range,
DataFrame, Index, MultiIndex, Series, Timestamp, date_range,
read_csv)
import pandas.core.common as com
import pandas.util.testing as tm
Expand Down Expand Up @@ -510,30 +510,30 @@ def test_frame_multi_key_function_list():


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

result1 = op(grouped)

expected = defaultdict(dict)
keys = []
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a little bit more movement on the test than I had hoped for but the original test mentions something of this reshaping to be "a little bit crude" so it may be in order; new test should have the same coverage but with less reshaping

values = []
for n1, gp1 in data.groupby('A'):
for n2, gp2 in gp1.groupby('B'):
expected[n1][n2] = op(gp2.loc[:, ['C', 'D']])
expected = {k: DataFrame(v)
for k, v in expected.items()}
expected = Panel.fromDict(expected).swapaxes(0, 1)
expected.major_axis.name, expected.minor_axis.name = 'A', 'B'
keys.append((n1, n2))
values.append(op(gp2.loc[:, ['C', 'D']]))

mi = MultiIndex.from_tuples(keys, names=['A', 'B'])
expected = pd.concat(values, axis=1).T
expected.index = mi

# a little bit crude
for col in ['C', 'D']:
result_col = op(grouped[col])
pivoted = result1[col]
exp = expected[col]
pivoted = result1[col].unstack()
pivoted2 = result_col.unstack()
assert_frame_equal(pivoted.reindex_like(exp), exp)
assert_frame_equal(pivoted2.reindex_like(exp), exp)
assert_series_equal(result_col, exp)
assert_series_equal(pivoted, exp)

# test single series works the same
result = data['C'].groupby([data['A'], data['B']]).mean()
Expand Down
1 change: 0 additions & 1 deletion pandas/tests/io/test_excel.py
Original file line number Diff line number Diff line change
Expand Up @@ -2350,7 +2350,6 @@ def test_ExcelWriter_dispatch_raises(self):
with pytest.raises(ValueError, match='No engine'):
ExcelWriter('nothing')

@pytest.mark.filterwarnings("ignore:\\nPanel:FutureWarning")
def test_register_writer(self):
# some awkward mocking to test out dispatch and such actually works
called_save = []
Expand Down
2 changes: 0 additions & 2 deletions pandas/tests/reshape/test_reshape.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,8 +587,6 @@ class TestCategoricalReshape:

def test_reshaping_multi_index_categorical(self):

# construct a MultiIndexed DataFrame formerly created
# via `tm.makePanel().to_frame()`
cols = ['ItemA', 'ItemB', 'ItemC']
data = {c: tm.makeTimeDataFrame() for c in cols}
df = pd.concat({c: data[c].stack() for c in data}, axis='columns')
Expand Down
6 changes: 2 additions & 4 deletions pandas/tests/sparse/frame/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from pandas.errors import PerformanceWarning

import pandas as pd
from pandas import DataFrame, Panel, Series, bdate_range, compat
from pandas import DataFrame, Series, bdate_range, compat
from pandas.core.indexes.datetimes import DatetimeIndex
from pandas.core.sparse import frame as spf
from pandas.core.sparse.api import (
Expand Down Expand Up @@ -1053,14 +1053,12 @@ def _check(frame, orig):
_check(float_frame_fill0, float_frame_fill0_dense)
_check(float_frame_fill2, float_frame_fill2_dense)

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

wp = Panel.from_dict({'foo': frame})
from_dense_lp = wp.to_frame()
from_dense_lp = frame.stack().to_frame()

from_sparse_lp = spf.stack_sparse_frame(frame)

Expand Down