-
-
Notifications
You must be signed in to change notification settings - Fork 145
GH1246 Upgrade to pandas 2.3.0 #1247
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 1 commit
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 |
---|---|---|
|
@@ -48,7 +48,6 @@ | |
from pandas._typing import Scalar | ||
|
||
from tests import ( | ||
PD_LTE_22, | ||
PD_LTE_23, | ||
TYPE_CHECKING_INVALID_USAGE, | ||
check, | ||
|
@@ -1542,21 +1541,6 @@ def test_types_groupby() -> None: | |
assert_type(df.groupby(by=["col1", "col2"]).nunique(), pd.DataFrame), | ||
pd.DataFrame, | ||
) | ||
with pytest_warns_bounded( | ||
FutureWarning, | ||
"(The provided callable <built-in function sum> is currently using|The behavior of DataFrame.sum with)", | ||
upper="2.2.99", | ||
): | ||
with pytest_warns_bounded( | ||
DeprecationWarning, | ||
"DataFrameGroupBy.apply operated on the grouping columns", | ||
upper="2.2.99", | ||
): | ||
if PD_LTE_22: | ||
check( | ||
assert_type(df.groupby(by="col1").apply(sum), pd.DataFrame), | ||
pd.DataFrame, | ||
) | ||
check(assert_type(df.groupby("col1").transform("sum"), pd.DataFrame), pd.DataFrame) | ||
s1 = df.set_index("col1")["col2"] | ||
check(assert_type(s1, pd.Series), pd.Series) | ||
|
@@ -3134,19 +3118,17 @@ def test_frame_stack() -> None: | |
def test_frame_reindex() -> None: | ||
# GH 84 | ||
df = pd.DataFrame({"a": [1, 2, 3]}, index=[0, 1, 2]) | ||
df.reindex([2, 1, 0]) | ||
check(assert_type(df.reindex([2, 1, 0]), pd.DataFrame), pd.DataFrame) | ||
|
||
|
||
def test_frame_reindex_like() -> None: | ||
# GH 84 | ||
df = pd.DataFrame({"a": [1, 2, 3]}, index=[0, 1, 2]) | ||
other = pd.DataFrame({"a": [1, 2]}, index=[1, 0]) | ||
|
||
with pytest_warns_bounded( | ||
FutureWarning, | ||
"the 'method' keyword is deprecated and will be removed in a future version. Please take steps to stop the use of 'method'", | ||
lower="2.2.99", | ||
upper="2.2.99", | ||
lower="2.3.0", | ||
): | ||
check( | ||
assert_type( | ||
|
@@ -3449,72 +3431,45 @@ def test_groupby_apply() -> None: | |
def sum_mean(x: pd.DataFrame) -> float: | ||
return x.sum().mean() | ||
|
||
with ( | ||
pytest_warns_bounded( | ||
DeprecationWarning, | ||
"DataFrameGroupBy.apply operated on the grouping columns.", | ||
upper="2.2.99", | ||
), | ||
pytest_warns_bounded( | ||
FutureWarning, | ||
"DataFrameGroupBy.apply operated on the grouping columns.", | ||
lower="2.2.99", | ||
upper="2.3.99", | ||
), | ||
with pytest_warns_bounded( | ||
FutureWarning, | ||
"DataFrameGroupBy.apply operated on the grouping columns.", | ||
lower="2.2.99", | ||
upper="2.3.99", | ||
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. keep this at |
||
): | ||
check( | ||
assert_type(df.groupby("col1").apply(sum_mean), pd.Series), | ||
pd.Series, | ||
) | ||
|
||
lfunc: Callable[[pd.DataFrame], float] = lambda x: x.sum().mean() | ||
with ( | ||
pytest_warns_bounded( | ||
DeprecationWarning, | ||
"DataFrameGroupBy.apply operated on the grouping columns.", | ||
upper="2.2.99", | ||
), | ||
pytest_warns_bounded( | ||
FutureWarning, | ||
"DataFrameGroupBy.apply operated on the grouping columns.", | ||
lower="2.2.99", | ||
), | ||
with pytest_warns_bounded( | ||
FutureWarning, | ||
"DataFrameGroupBy.apply operated on the grouping columns.", | ||
lower="2.2.99", | ||
upper="2.99.99", | ||
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. keep this at |
||
): | ||
check(assert_type(df.groupby("col1").apply(lfunc), pd.Series), pd.Series) | ||
|
||
def sum_to_list(x: pd.DataFrame) -> list: | ||
return x.sum().tolist() | ||
|
||
with ( | ||
pytest_warns_bounded( | ||
DeprecationWarning, | ||
"DataFrameGroupBy.apply operated on the grouping columns.", | ||
upper="2.2.99", | ||
), | ||
pytest_warns_bounded( | ||
FutureWarning, | ||
"DataFrameGroupBy.apply operated on the grouping columns.", | ||
lower="2.2.99", | ||
upper="2.3.99", | ||
), | ||
with pytest_warns_bounded( | ||
FutureWarning, | ||
"DataFrameGroupBy.apply operated on the grouping columns.", | ||
lower="2.2.99", | ||
upper="2.3.99", | ||
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. keep this at |
||
): | ||
check(assert_type(df.groupby("col1").apply(sum_to_list), pd.Series), pd.Series) | ||
|
||
def sum_to_series(x: pd.DataFrame) -> pd.Series: | ||
return x.sum() | ||
|
||
with ( | ||
pytest_warns_bounded( | ||
DeprecationWarning, | ||
"DataFrameGroupBy.apply operated on the grouping columns.", | ||
upper="2.2.99", | ||
), | ||
pytest_warns_bounded( | ||
FutureWarning, | ||
"DataFrameGroupBy.apply operated on the grouping columns.", | ||
lower="2.2.99", | ||
upper="2.3.99", | ||
), | ||
with pytest_warns_bounded( | ||
FutureWarning, | ||
"DataFrameGroupBy.apply operated on the grouping columns.", | ||
lower="2.2.99", | ||
upper="2.3.99", | ||
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. keep this at |
||
): | ||
check( | ||
assert_type(df.groupby("col1").apply(sum_to_series), pd.DataFrame), | ||
|
@@ -3524,18 +3479,11 @@ def sum_to_series(x: pd.DataFrame) -> pd.Series: | |
def sample_to_df(x: pd.DataFrame) -> pd.DataFrame: | ||
return x.sample() | ||
|
||
with ( | ||
pytest_warns_bounded( | ||
DeprecationWarning, | ||
"DataFrameGroupBy.apply operated on the grouping columns.", | ||
upper="2.2.99", | ||
), | ||
pytest_warns_bounded( | ||
FutureWarning, | ||
"DataFrameGroupBy.apply operated on the grouping columns.", | ||
lower="2.2.99", | ||
upper="2.3.99", | ||
), | ||
with pytest_warns_bounded( | ||
FutureWarning, | ||
"DataFrameGroupBy.apply operated on the grouping columns.", | ||
lower="2.2.99", | ||
upper="2.3.99", | ||
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. keep this at |
||
): | ||
check( | ||
assert_type( | ||
|
@@ -4424,13 +4372,12 @@ def test_transpose() -> None: | |
df = pd.DataFrame({"a": [1, 1, 2], "b": [4, 5, 6]}) | ||
check(assert_type(df.transpose(), pd.DataFrame), pd.DataFrame) | ||
check(assert_type(df.transpose(None), pd.DataFrame), pd.DataFrame) | ||
|
||
msg = "The copy keyword is deprecated and will be removed in a future" | ||
with pytest_warns_bounded( | ||
DeprecationWarning, | ||
msg, | ||
lower="2.2.99", | ||
upper="2.2.99", | ||
lower="2.3.99", | ||
upper="3.0.0", | ||
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. remove the |
||
): | ||
check(assert_type(df.transpose(copy=True), pd.DataFrame), pd.DataFrame) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,18 +77,11 @@ def test_frame_groupby_resample() -> None: | |
check(assert_type(GB_DF.resample("ME").ax, Index), DatetimeIndex) | ||
|
||
# agg funcs | ||
with ( | ||
pytest_warns_bounded( | ||
DeprecationWarning, | ||
"DataFrameGroupBy.(apply|resample) operated on the grouping columns", | ||
upper="2.2.99", | ||
), | ||
pytest_warns_bounded( | ||
FutureWarning, | ||
"DataFrameGroupBy.(apply|resample) operated on the grouping columns", | ||
lower="2.2.99", | ||
upper="2.3.99", | ||
), | ||
with pytest_warns_bounded( | ||
FutureWarning, | ||
"DataFrameGroupBy.(apply|resample) operated on the grouping columns", | ||
lower="2.2.99", | ||
upper="2.3.99", | ||
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. keep this at |
||
): | ||
check(assert_type(GB_DF.resample("ME").sum(), DataFrame), DataFrame) | ||
check(assert_type(GB_DF.resample("ME").prod(), DataFrame), DataFrame) | ||
|
@@ -132,18 +125,11 @@ def test_frame_groupby_resample() -> None: | |
GB_DF.resample("ME").fillna("ffill") # type: ignore[operator] # pyright: ignore | ||
|
||
# aggregate / apply | ||
with ( | ||
pytest_warns_bounded( | ||
DeprecationWarning, | ||
"DataFrameGroupBy.(apply|resample) operated on the grouping columns", | ||
upper="2.2.99", | ||
), | ||
pytest_warns_bounded( | ||
FutureWarning, | ||
"DataFrameGroupBy.(apply|resample) operated on the grouping columns", | ||
lower="2.2.99", | ||
upper="2.3.99", | ||
), | ||
with pytest_warns_bounded( | ||
FutureWarning, | ||
"DataFrameGroupBy.(apply|resample) operated on the grouping columns", | ||
lower="2.2.99", | ||
upper="2.3.99", | ||
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. keep this at |
||
): | ||
with pytest_warns_bounded( | ||
FutureWarning, | ||
|
@@ -188,18 +174,11 @@ def test_frame_groupby_resample() -> None: | |
def f(val: DataFrame) -> Series: | ||
return val.mean() | ||
|
||
with ( | ||
pytest_warns_bounded( | ||
DeprecationWarning, | ||
"DataFrameGroupBy.(apply|resample) operated on the grouping columns", | ||
upper="2.2.99", | ||
), | ||
pytest_warns_bounded( | ||
FutureWarning, | ||
"DataFrameGroupBy.(apply|resample) operated on the grouping columns", | ||
lower="2.2.99", | ||
upper="2.3.99", | ||
), | ||
with pytest_warns_bounded( | ||
FutureWarning, | ||
"DataFrameGroupBy.(apply|resample) operated on the grouping columns", | ||
lower="2.2.99", | ||
upper="2.3.99", | ||
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. keep this at |
||
): | ||
check(assert_type(GB_DF.resample("ME").aggregate(f), DataFrame), DataFrame) | ||
|
||
|
@@ -213,18 +192,11 @@ def df2series(val: DataFrame) -> Series: | |
def df2scalar(val: DataFrame) -> float: | ||
return float(val.mean().mean()) | ||
|
||
with ( | ||
pytest_warns_bounded( | ||
DeprecationWarning, | ||
"DataFrameGroupBy.(apply|resample) operated on the grouping columns", | ||
upper="2.2.99", | ||
), | ||
pytest_warns_bounded( | ||
FutureWarning, | ||
"DataFrameGroupBy.(apply|resample) operated on the grouping columns", | ||
lower="2.2.99", | ||
upper="2.3.99", | ||
), | ||
with pytest_warns_bounded( | ||
FutureWarning, | ||
"DataFrameGroupBy.(apply|resample) operated on the grouping columns", | ||
lower="2.2.99", | ||
upper="2.3.99", | ||
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. keep this at |
||
): | ||
with pytest_warns_bounded( | ||
FutureWarning, | ||
|
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.
This test needs to remain, but use 2
FutureWarning
withupper="2.3.99"
and have a check onPD_LTE_23