Skip to content

CLN: remove Panel from concat error message #25676

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 1 commit into from
Mar 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
8 changes: 4 additions & 4 deletions pandas/core/reshape/concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,10 @@ def __init__(self, objs, axis=0, join='outer', join_axes=None,
# consolidate data & figure out what our result ndim is going to be
ndims = set()
for obj in objs:
if not isinstance(obj, NDFrame):
msg = ('cannot concatenate object of type "{0}";'
' only pd.Series, pd.DataFrame, and pd.Panel'
' (deprecated) objs are valid'.format(type(obj)))
if not isinstance(obj, (Series, DataFrame)):
msg = ("cannot concatenate object of type '{}';"
' only Series and DataFrame objs are valid'
.format(type(obj)))
raise TypeError(msg)

# consolidate
Expand Down
45 changes: 7 additions & 38 deletions pandas/tests/reshape/test_concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import pandas as pd
from pandas import (
Categorical, DataFrame, DatetimeIndex, Index, MultiIndex, Panel, Series,
Categorical, DataFrame, DatetimeIndex, Index, MultiIndex, Series,
Timestamp, concat, date_range, isna, read_csv)
from pandas.tests.extension.decimal import to_decimal
from pandas.util import testing as tm
Expand Down Expand Up @@ -196,9 +196,8 @@ def test_concatlike_same_dtypes(self):
tm.assert_series_equal(res, exp, check_index_type=True)

# cannot append non-index
msg = (r'cannot concatenate object of type \"(.+?)\";'
' only pd.Series, pd.DataFrame, and pd.Panel'
r' \(deprecated\) objs are valid')
msg = (r"cannot concatenate object of type '.+';"
" only Series and DataFrame objs are valid")
with pytest.raises(TypeError, match=msg):
pd.Series(vals1).append(vals2)

Expand Down Expand Up @@ -1534,33 +1533,6 @@ def test_dtype_coerceion(self):
result = concat([df.iloc[[0]], df.iloc[[1]]])
tm.assert_series_equal(result.dtypes, df.dtypes)

@pytest.mark.filterwarnings("ignore:\\nPanel:FutureWarning")
# Panel.rename warning we don't care about
@pytest.mark.filterwarnings("ignore:Using:FutureWarning")
def test_panel_concat_buglet(self, sort):
# #2257
def make_panel():
index = 5
cols = 3

def df():
return DataFrame(np.random.randn(index, cols),
index=["I%s" % i for i in range(index)],
columns=["C%s" % i for i in range(cols)])
return Panel({"Item%s" % x: df() for x in ['A', 'B', 'C']})

panel1 = make_panel()
panel2 = make_panel()

panel2 = panel2.rename(major_axis={x: "%s_1" % x
for x in panel2.major_axis})

panel3 = panel2.rename(major_axis=lambda x: '%s_1' % x)
panel3 = panel3.rename(minor_axis=lambda x: '%s_1' % x)

# it works!
concat([panel1, panel3], axis=1, verify_integrity=True, sort=sort)

def test_concat_series(self):

ts = tm.makeTimeSeries()
Expand Down Expand Up @@ -1781,9 +1753,8 @@ def test_concat_invalid(self):

# trying to concat a ndframe with a non-ndframe
df1 = mkdf(10, 2)
msg = ('cannot concatenate object of type "{}";'
' only pd.Series, pd.DataFrame, and pd.Panel'
r' \(deprecated\) objs are valid')
msg = ("cannot concatenate object of type '{}';"
" only Series and DataFrame objs are valid")
for obj in [1, dict(), [1, 2], (1, 2)]:
with pytest.raises(TypeError, match=msg.format(type(obj))):
concat([df1, obj])
Expand Down Expand Up @@ -2400,9 +2371,8 @@ def test_concat_different_extension_dtypes_upcasts(self):
tm.assert_series_equal(result, expected)


@pytest.mark.parametrize('pdt', [pd.Series, pd.DataFrame, pd.Panel])
@pytest.mark.parametrize('pdt', [pd.Series, pd.DataFrame])
@pytest.mark.parametrize('dt', np.sctypes['float'])
@pytest.mark.filterwarnings("ignore:\\nPanel:FutureWarning")
def test_concat_no_unnecessary_upcast(dt, pdt):
# GH 13247
dims = pdt().ndim
Expand All @@ -2413,9 +2383,8 @@ def test_concat_no_unnecessary_upcast(dt, pdt):
assert x.values.dtype == dt


@pytest.mark.parametrize('pdt', [pd.Series, pd.DataFrame, pd.Panel])
@pytest.mark.parametrize('pdt', [pd.Series, pd.DataFrame])
@pytest.mark.parametrize('dt', np.sctypes['int'])
@pytest.mark.filterwarnings("ignore:\\nPanel:FutureWarning")
def test_concat_will_upcast(dt, pdt):
with catch_warnings(record=True):
dims = pdt().ndim
Expand Down