-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Move GroupBy to Submodule and Add FutureWarning #20506
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
Changes from 3 commits
8eff7db
37e5f1c
6bd1301
2485a15
ec8395f
884850a
9acba5c
a07fe88
1f20857
7d29785
2b2d59d
0f01b4c
8867133
97f349a
db4abbe
da6f676
7624313
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import warnings | ||
|
||
# TODO: Remove after 0.XX.x | ||
warnings.warn("'pandas.core.groupby' has moved. Use " | ||
"'pandas.core.groupby.groupby' instead", FutureWarning, | ||
stacklevel=2) | ||
|
||
from pandas.core.groupby.groupby import Grouper # noqa: F401 | ||
from pandas.core.groupby.groupby import groupby # noqa: F401 | ||
from pandas.core.groupby.groupby import BinGrouper # noqa: F401 | ||
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. only put public functions here. If something is needed internally then change the reference to it. |
||
from pandas.core.groupby.groupby import _GroupBy # noqa: F401 | ||
from pandas.core.groupby.groupby import GroupBy # noqa: F401 | ||
from pandas.core.groupby.groupby import SeriesGroupBy # noqa: F401 | ||
from pandas.core.groupby.groupby import _pipe_template # noqa: F401 | ||
from pandas.core.groupby.groupby import PanelGroupBy # noqa: F401 | ||
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. are all these imports actually needed? just change where they r used |
||
from pandas.core.groupby.groupby import Grouping # noqa: F401 | ||
from pandas.core.groupby.groupby import SpecificationError # noqa: F401 | ||
from pandas.core.groupby.groupby import DataError # noqa: F401 | ||
from pandas.core.groupby.groupby import generate_bins_generic # noqa: F401 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -238,7 +238,7 @@ def test_deprecation_cdaterange(self): | |
cdate_range('2017-01-01', '2017-12-31') | ||
|
||
|
||
class TestCategoricalMove(object): | ||
class TestModuleMoves(object): | ||
|
||
def test_categorical_move(self): | ||
# May have been cached by another import, e.g. pickle tests. | ||
|
@@ -251,3 +251,16 @@ def test_categorical_move(self): | |
|
||
with tm.assert_produces_warning(FutureWarning): | ||
from pandas.core.categorical import CategoricalDtype # noqa | ||
|
||
@pytest.mark.parametrize("attr", [ | ||
"Grouper", "groupby", "BinGrouper", "Grouper", "_GroupBy", "GroupBy", | ||
"SeriesGroupBy", "_pipe_template", "PanelGroupBy", "Grouping", | ||
"SpecificationError", "DataError", "generate_bins_generic"]) | ||
def test_groupby_move(self, attr): | ||
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. This would be straightforward to combine with the method above if we wanted one test accepting a module / list of objects to test the deprecation for |
||
# May have been cached by another import, e.g. pickle tests. | ||
sys.modules.pop("pandas.core.groupby", None) | ||
|
||
with tm.assert_produces_warning(FutureWarning): | ||
import pandas.core.groupby as grpby # noqa | ||
|
||
getattr(grpby, attr) |
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.
can u import these in 1 statement