-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
using DataFrame.resample with 'agg' method on non-existant columns provides unexpected behavior #19552
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
using DataFrame.resample with 'agg' method on non-existant columns provides unexpected behavior #19552
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,6 @@ | |
|
||
from pandas.core.dtypes.generic import ABCSeries, ABCDataFrame | ||
from pandas.compat import range, lrange, zip, product, OrderedDict | ||
from pandas.core.base import SpecificationError | ||
from pandas.errors import UnsupportedFunctionCall | ||
from pandas.core.groupby import DataError | ||
import pandas.core.common as com | ||
|
@@ -614,7 +613,7 @@ def f(): | |
t[['A']].agg({'A': ['sum', 'std'], | ||
'B': ['mean', 'std']}) | ||
|
||
pytest.raises(SpecificationError, f) | ||
pytest.raises(ValueError, f) | ||
|
||
def test_agg_nested_dicts(self): | ||
|
||
|
@@ -659,6 +658,21 @@ def f(): | |
'B': {'rb': ['mean', 'std']}}) | ||
assert_frame_equal(result, expected, check_like=True) | ||
|
||
def test_try_aggregate_non_existing_column(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure that this test is needed because There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good to keep it. |
||
# GH 16766 | ||
data = [ | ||
{'dt': datetime(2017, 6, 1, 0), 'x': 1.0, 'y': 2.0}, | ||
{'dt': datetime(2017, 6, 1, 1), 'x': 2.0, 'y': 2.0}, | ||
{'dt': datetime(2017, 6, 1, 2), 'x': 3.0, 'y': 1.5} | ||
] | ||
df = DataFrame(data).set_index('dt') | ||
|
||
# Error as we don't have 'z' column | ||
with pytest.raises(ValueError): | ||
df.resample('30T').agg({'x': ['mean'], | ||
'y': ['median'], | ||
'z': ['sum']}) | ||
|
||
def test_selection_api_validation(self): | ||
# GH 13500 | ||
index = date_range(datetime(2005, 1, 1), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actuallly I think this should be a KeyError. can you do another PR to fix?