Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
topper-123 committed Apr 1, 2023
1 parent 6a0f6c2 commit fe857a4
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions pandas/tests/apply/test_series_apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,15 +381,16 @@ def test_agg_apply_evaluate_lambdas_the_same(string_series):
def test_with_nested_series(datetime_series):
# GH 2316
# .agg with a reducer and a transform, what to do
with tm.assert_produces_warning(FutureWarning, match="converting list of Series"):
msg = "Returning a DataFrame from Series.apply when the supplied function"
with tm.assert_produces_warning(FutureWarning, match=msg):
# GH52123
result = datetime_series.apply(
lambda x: Series([x, x**2], index=["x", "x^2"])
)
expected = DataFrame({"x": datetime_series, "x^2": datetime_series**2})
tm.assert_frame_equal(result, expected)

with tm.assert_produces_warning(FutureWarning, match="converting list of Series"):
with tm.assert_produces_warning(FutureWarning, match=msg):
# GH52123
result = datetime_series.agg(lambda x: Series([x, x**2], index=["x", "x^2"]))
tm.assert_frame_equal(result, expected)
Expand Down Expand Up @@ -863,7 +864,8 @@ def test_apply_series_on_date_time_index_aware_series(dti, exp, aware):
index = dti.tz_localize("UTC").index
else:
index = dti.index
with tm.assert_produces_warning(FutureWarning, match="converting list of Series"):
msg = "Returning a DataFrame from Series.apply when the supplied function"
with tm.assert_produces_warning(FutureWarning, match=msg):
# GH52123
result = Series(index).apply(lambda x: Series([1, 2]))
tm.assert_frame_equal(result, exp)
Expand Down Expand Up @@ -975,7 +977,8 @@ def test_apply_retains_column_name():
# GH 16380
df = DataFrame({"x": range(3)}, Index(range(3), name="x"))
func = lambda x: Series(range(x + 1), Index(range(x + 1), name="y"))
with tm.assert_produces_warning(FutureWarning, match="converting list of Series"):
msg = "Returning a DataFrame from Series.apply when the supplied function"
with tm.assert_produces_warning(FutureWarning, match=msg):
# GH52123
result = df.x.apply(func)
expected = DataFrame(
Expand Down

0 comments on commit fe857a4

Please sign in to comment.