Skip to content

Commit 43601bc

Browse files
committed
Fixed testing errors
1 parent 10fd532 commit 43601bc

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

pandas/core/base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -356,11 +356,11 @@ def _aggregate(self, arg, *args, **kwargs):
356356
if isinstance(obj, ABCDataFrame) and len(
357357
obj.columns.intersection(keys)
358358
) != len(keys):
359-
cols = set(keys) - set(obj.columns.intersection(keys))
359+
cols = sorted(set(keys) - set(obj.columns.intersection(keys)))
360360
if len(cols) > 1:
361-
raise SpecificationError(f"Columns '{cols}' do not exist")
361+
raise SpecificationError(f"Columns {cols} do not exist")
362362
else:
363-
raise SpecificationError(f"Column '{cols}' does not exist")
363+
raise SpecificationError(f"Column {cols} does not exist")
364364

365365
from pandas.core.reshape.concat import concat
366366

pandas/tests/groupby/aggregate/test_other.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ def test_aggregate_api_consistency():
209209
expected = pd.concat([c_mean, c_sum, d_mean, d_sum], axis=1)
210210
expected.columns = MultiIndex.from_product([["C", "D"], ["mean", "sum"]])
211211

212-
msg = r"Columns '{'r', 'r2'}' do not exist"
212+
msg = r"Columns \['r', 'r2'\] do not exist"
213213
with pytest.raises(SpecificationError, match=msg):
214214
grouped[["D", "C"]].agg({"r": np.sum, "r2": np.mean})
215215

@@ -224,11 +224,11 @@ def test_agg_dict_renaming_deprecation():
224224
{"B": {"foo": ["sum", "max"]}, "C": {"bar": ["count", "min"]}}
225225
)
226226

227-
msg = r"Column '{'ma'}' does not exist"
227+
msg = r"Column \['ma'\] does not exist"
228228
with pytest.raises(SpecificationError, match=msg):
229229
df.groupby("A")[["B", "C"]].agg({"ma": "max"})
230230

231-
msg = r"Column '{'foo}' does not exist"
231+
msg = r"nested renamer is not supported"
232232
with pytest.raises(SpecificationError, match=msg):
233233
df.groupby("A").B.agg({"foo": "count"})
234234

pandas/tests/resample/test_resample_api.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ def test_agg_consistency():
287287

288288
r = df.resample("3T")
289289

290-
msg = "Columns '{'r1', 'r2'}' do not exist"
290+
msg = r"Columns \['r1', 'r2'\] do not exist"
291291
with pytest.raises(pd.core.base.SpecificationError, match=msg):
292292
r.agg({"r1": "mean", "r2": "sum"})
293293

@@ -419,7 +419,7 @@ def test_agg_misc():
419419
[("result1", "A"), ("result1", "B"), ("result2", "A"), ("result2", "B")]
420420
)
421421

422-
msg = "Columns '{'result2', 'result1'}' do not exist"
422+
msg = r"Columns \['result1', 'result2'\] do not exist"
423423
for t in cases:
424424
with pytest.raises(pd.core.base.SpecificationError, match=msg):
425425
t[["A", "B"]].agg(OrderedDict([("result1", np.sum), ("result2", np.mean)]))
@@ -440,6 +440,8 @@ def test_agg_misc():
440440
result = t[["A", "B"]].agg({"A": ["sum", "std"], "B": ["mean", "std"]})
441441
tm.assert_frame_equal(result, expected, check_like=True)
442442

443+
msg = "nested renamer is not supported"
444+
443445
# series like aggs
444446
for t in cases:
445447
with pytest.raises(pd.core.base.SpecificationError, match=msg):

0 commit comments

Comments
 (0)