Skip to content

Commit b2fe489

Browse files
committed
ERR: raise KeyError on invalid column name in aggregate
xref pandas-dev#19552
1 parent ccf9677 commit b2fe489

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

pandas/core/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ def nested_renaming_depr(level=4):
394394
nested_renaming_depr()
395395
elif isinstance(obj, ABCDataFrame) and \
396396
k not in obj.columns:
397-
raise ValueError(
397+
raise KeyError(
398398
"Column '{col}' does not exist!".format(col=k))
399399

400400
arg = new_arg

pandas/tests/test_resample.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ def f():
613613
t[['A']].agg({'A': ['sum', 'std'],
614614
'B': ['mean', 'std']})
615615

616-
pytest.raises(ValueError, f)
616+
pytest.raises(KeyError, f)
617617

618618
def test_agg_nested_dicts(self):
619619

@@ -668,7 +668,7 @@ def test_try_aggregate_non_existing_column(self):
668668
df = DataFrame(data).set_index('dt')
669669

670670
# Error as we don't have 'z' column
671-
with pytest.raises(ValueError):
671+
with pytest.raises(KeyError):
672672
df.resample('30T').agg({'x': ['mean'],
673673
'y': ['median'],
674674
'z': ['sum']})

0 commit comments

Comments
 (0)