@@ -166,7 +166,7 @@ def max_value(group):
166
166
return group .loc [group ["value" ].idxmax ()]
167
167
168
168
msg = "DataFrameGroupBy.apply operated on the grouping columns"
169
- with tm .assert_produces_warning (DeprecationWarning , match = msg ):
169
+ with tm .assert_produces_warning (FutureWarning , match = msg ):
170
170
applied = df .groupby ("A" ).apply (max_value )
171
171
result = applied .dtypes
172
172
expected = df .dtypes
@@ -189,7 +189,7 @@ def f_0(grp):
189
189
190
190
expected = df .groupby ("A" ).first ()[["B" ]]
191
191
msg = "DataFrameGroupBy.apply operated on the grouping columns"
192
- with tm .assert_produces_warning (DeprecationWarning , match = msg ):
192
+ with tm .assert_produces_warning (FutureWarning , match = msg ):
193
193
result = df .groupby ("A" ).apply (f_0 )[["B" ]]
194
194
tm .assert_frame_equal (result , expected )
195
195
@@ -199,7 +199,7 @@ def f_1(grp):
199
199
return grp .iloc [0 ]
200
200
201
201
msg = "DataFrameGroupBy.apply operated on the grouping columns"
202
- with tm .assert_produces_warning (DeprecationWarning , match = msg ):
202
+ with tm .assert_produces_warning (FutureWarning , match = msg ):
203
203
result = df .groupby ("A" ).apply (f_1 )[["B" ]]
204
204
e = expected .copy ()
205
205
e .loc ["Tiger" ] = np .nan
@@ -211,7 +211,7 @@ def f_2(grp):
211
211
return grp .iloc [0 ]
212
212
213
213
msg = "DataFrameGroupBy.apply operated on the grouping columns"
214
- with tm .assert_produces_warning (DeprecationWarning , match = msg ):
214
+ with tm .assert_produces_warning (FutureWarning , match = msg ):
215
215
result = df .groupby ("A" ).apply (f_2 )[["B" ]]
216
216
e = expected .copy ()
217
217
e .loc ["Pony" ] = np .nan
@@ -224,7 +224,7 @@ def f_3(grp):
224
224
return grp .iloc [0 ]
225
225
226
226
msg = "DataFrameGroupBy.apply operated on the grouping columns"
227
- with tm .assert_produces_warning (DeprecationWarning , match = msg ):
227
+ with tm .assert_produces_warning (FutureWarning , match = msg ):
228
228
result = df .groupby ("A" ).apply (f_3 )[["C" ]]
229
229
e = df .groupby ("A" ).first ()[["C" ]]
230
230
e .loc ["Pony" ] = pd .NaT
@@ -237,7 +237,7 @@ def f_4(grp):
237
237
return grp .iloc [0 ].loc ["C" ]
238
238
239
239
msg = "DataFrameGroupBy.apply operated on the grouping columns"
240
- with tm .assert_produces_warning (DeprecationWarning , match = msg ):
240
+ with tm .assert_produces_warning (FutureWarning , match = msg ):
241
241
result = df .groupby ("A" ).apply (f_4 )
242
242
e = df .groupby ("A" ).first ()["C" ].copy ()
243
243
e .loc ["Pony" ] = np .nan
@@ -424,9 +424,9 @@ def f3(x):
424
424
425
425
# correct result
426
426
msg = "DataFrameGroupBy.apply operated on the grouping columns"
427
- with tm .assert_produces_warning (DeprecationWarning , match = msg ):
427
+ with tm .assert_produces_warning (FutureWarning , match = msg ):
428
428
result1 = df .groupby ("a" ).apply (f1 )
429
- with tm .assert_produces_warning (DeprecationWarning , match = msg ):
429
+ with tm .assert_produces_warning (FutureWarning , match = msg ):
430
430
result2 = df2 .groupby ("a" ).apply (f1 )
431
431
tm .assert_frame_equal (result1 , result2 )
432
432
@@ -1379,13 +1379,13 @@ def summarize_random_name(df):
1379
1379
return Series ({"count" : 1 , "mean" : 2 , "omissions" : 3 }, name = df .iloc [0 ]["A" ])
1380
1380
1381
1381
msg = "DataFrameGroupBy.apply operated on the grouping columns"
1382
- with tm .assert_produces_warning (DeprecationWarning , match = msg ):
1382
+ with tm .assert_produces_warning (FutureWarning , match = msg ):
1383
1383
metrics = df .groupby ("A" ).apply (summarize )
1384
1384
assert metrics .columns .name is None
1385
- with tm .assert_produces_warning (DeprecationWarning , match = msg ):
1385
+ with tm .assert_produces_warning (FutureWarning , match = msg ):
1386
1386
metrics = df .groupby ("A" ).apply (summarize , "metrics" )
1387
1387
assert metrics .columns .name == "metrics"
1388
- with tm .assert_produces_warning (DeprecationWarning , match = msg ):
1388
+ with tm .assert_produces_warning (FutureWarning , match = msg ):
1389
1389
metrics = df .groupby ("A" ).apply (summarize_random_name )
1390
1390
assert metrics .columns .name is None
1391
1391
@@ -1681,7 +1681,7 @@ def test_dont_clobber_name_column():
1681
1681
)
1682
1682
1683
1683
msg = "DataFrameGroupBy.apply operated on the grouping columns"
1684
- with tm .assert_produces_warning (DeprecationWarning , match = msg ):
1684
+ with tm .assert_produces_warning (FutureWarning , match = msg ):
1685
1685
result = df .groupby ("key" , group_keys = False ).apply (lambda x : x )
1686
1686
tm .assert_frame_equal (result , df )
1687
1687
@@ -1769,7 +1769,7 @@ def freducex(x):
1769
1769
1770
1770
# make sure all these work
1771
1771
msg = "DataFrameGroupBy.apply operated on the grouping columns"
1772
- with tm .assert_produces_warning (DeprecationWarning , match = msg ):
1772
+ with tm .assert_produces_warning (FutureWarning , match = msg ):
1773
1773
grouped .apply (f )
1774
1774
grouped .aggregate (freduce )
1775
1775
grouped .aggregate ({"C" : freduce , "D" : freduce })
@@ -1792,7 +1792,7 @@ def f(group):
1792
1792
return group .copy ()
1793
1793
1794
1794
msg = "DataFrameGroupBy.apply operated on the grouping columns"
1795
- with tm .assert_produces_warning (DeprecationWarning , match = msg ):
1795
+ with tm .assert_produces_warning (FutureWarning , match = msg ):
1796
1796
df .groupby ("a" , sort = False , group_keys = False ).apply (f )
1797
1797
1798
1798
expected_names = [0 , 1 , 2 ]
@@ -2000,7 +2000,7 @@ def test_sort(x):
2000
2000
tm .assert_frame_equal (x , x .sort_values (by = sort_column ))
2001
2001
2002
2002
msg = "DataFrameGroupBy.apply operated on the grouping columns"
2003
- with tm .assert_produces_warning (DeprecationWarning , match = msg ):
2003
+ with tm .assert_produces_warning (FutureWarning , match = msg ):
2004
2004
g .apply (test_sort )
2005
2005
2006
2006
@@ -2187,7 +2187,7 @@ def test_empty_groupby_apply_nonunique_columns():
2187
2187
df .columns = [0 , 1 , 2 , 0 ]
2188
2188
gb = df .groupby (df [1 ], group_keys = False )
2189
2189
msg = "DataFrameGroupBy.apply operated on the grouping columns"
2190
- with tm .assert_produces_warning (DeprecationWarning , match = msg ):
2190
+ with tm .assert_produces_warning (FutureWarning , match = msg ):
2191
2191
res = gb .apply (lambda x : x )
2192
2192
assert (res .dtypes == df .dtypes ).all ()
2193
2193
0 commit comments