forked from pandas-dev/pandas
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENH: add groupby & reduce support to EA (pandas-dev#22762)
- Loading branch information
Showing
18 changed files
with
269 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import warnings | ||
import pytest | ||
import pandas.util.testing as tm | ||
import pandas as pd | ||
from .base import BaseExtensionTests | ||
|
||
|
||
class BaseReduceTests(BaseExtensionTests): | ||
""" | ||
Reduction specific tests. Generally these only | ||
make sense for numeric/boolean operations. | ||
""" | ||
def check_reduce(self, s, op_name, skipna): | ||
result = getattr(s, op_name)(skipna=skipna) | ||
expected = getattr(s.astype('float64'), op_name)(skipna=skipna) | ||
tm.assert_almost_equal(result, expected) | ||
|
||
|
||
class BaseNoReduceTests(BaseReduceTests): | ||
""" we don't define any reductions """ | ||
|
||
@pytest.mark.parametrize('skipna', [True, False]) | ||
def test_reduce_series_numeric(self, data, all_numeric_reductions, skipna): | ||
op_name = all_numeric_reductions | ||
s = pd.Series(data) | ||
|
||
with pytest.raises(TypeError): | ||
getattr(s, op_name)(skipna=skipna) | ||
|
||
@pytest.mark.parametrize('skipna', [True, False]) | ||
def test_reduce_series_boolean(self, data, all_boolean_reductions, skipna): | ||
op_name = all_boolean_reductions | ||
s = pd.Series(data) | ||
|
||
with pytest.raises(TypeError): | ||
getattr(s, op_name)(skipna=skipna) | ||
|
||
|
||
class BaseNumericReduceTests(BaseReduceTests): | ||
|
||
@pytest.mark.parametrize('skipna', [True, False]) | ||
def test_reduce_series(self, data, all_numeric_reductions, skipna): | ||
op_name = all_numeric_reductions | ||
s = pd.Series(data) | ||
|
||
# min/max with empty produce numpy warnings | ||
with warnings.catch_warnings(): | ||
warnings.simplefilter("ignore", RuntimeWarning) | ||
self.check_reduce(s, op_name, skipna) | ||
|
||
|
||
class BaseBooleanReduceTests(BaseReduceTests): | ||
|
||
@pytest.mark.parametrize('skipna', [True, False]) | ||
def test_reduce_series(self, data, all_boolean_reductions, skipna): | ||
op_name = all_boolean_reductions | ||
s = pd.Series(data) | ||
self.check_reduce(s, op_name, skipna) |
Oops, something went wrong.