@@ -368,7 +368,7 @@ def test_loc_setitem_dtype(self):
368
368
df = DataFrame ({"id" : ["A" ], "a" : [1.2 ], "b" : [0.0 ], "c" : [- 2.5 ]})
369
369
cols = ["a" , "b" , "c" ]
370
370
msg = "will attempt to set the values inplace instead"
371
- with tm .assert_produces_warning (FutureWarning , match = msg ):
371
+ with tm .assert_produces_warning (DeprecationWarning , match = msg ):
372
372
df .loc [:, cols ] = df .loc [:, cols ].astype ("float32" )
373
373
374
374
expected = DataFrame (
@@ -633,11 +633,11 @@ def test_loc_setitem_consistency_slice_column_len(self):
633
633
df = DataFrame (values , index = mi , columns = cols )
634
634
635
635
msg = "will attempt to set the values inplace instead"
636
- with tm .assert_produces_warning (FutureWarning , match = msg ):
636
+ with tm .assert_produces_warning (DeprecationWarning , match = msg ):
637
637
df .loc [:, ("Respondent" , "StartDate" )] = to_datetime (
638
638
df .loc [:, ("Respondent" , "StartDate" )]
639
639
)
640
- with tm .assert_produces_warning (FutureWarning , match = msg ):
640
+ with tm .assert_produces_warning (DeprecationWarning , match = msg ):
641
641
df .loc [:, ("Respondent" , "EndDate" )] = to_datetime (
642
642
df .loc [:, ("Respondent" , "EndDate" )]
643
643
)
@@ -720,7 +720,7 @@ def test_loc_setitem_frame_with_reindex_mixed(self):
720
720
df = DataFrame (index = [3 , 5 , 4 ], columns = ["A" , "B" ], dtype = float )
721
721
df ["B" ] = "string"
722
722
msg = "will attempt to set the values inplace instead"
723
- with tm .assert_produces_warning (FutureWarning , match = msg ):
723
+ with tm .assert_produces_warning (DeprecationWarning , match = msg ):
724
724
df .loc [[4 , 3 , 5 ], "A" ] = np .array ([1 , 2 , 3 ], dtype = "int64" )
725
725
ser = Series ([2 , 3 , 1 ], index = [3 , 5 , 4 ], dtype = "int64" )
726
726
expected = DataFrame ({"A" : ser })
@@ -732,7 +732,7 @@ def test_loc_setitem_frame_with_inverted_slice(self):
732
732
df = DataFrame (index = [1 , 2 , 3 ], columns = ["A" , "B" ], dtype = float )
733
733
df ["B" ] = "string"
734
734
msg = "will attempt to set the values inplace instead"
735
- with tm .assert_produces_warning (FutureWarning , match = msg ):
735
+ with tm .assert_produces_warning (DeprecationWarning , match = msg ):
736
736
df .loc [slice (3 , 0 , - 1 ), "A" ] = np .array ([1 , 2 , 3 ], dtype = "int64" )
737
737
expected = DataFrame ({"A" : [3 , 2 , 1 ], "B" : "string" }, index = [1 , 2 , 3 ])
738
738
tm .assert_frame_equal (df , expected )
@@ -909,7 +909,7 @@ def test_loc_setitem_missing_columns(self, index, box, expected):
909
909
910
910
warn = None
911
911
if isinstance (index [0 ], slice ) and index [0 ] == slice (None ):
912
- warn = FutureWarning
912
+ warn = DeprecationWarning
913
913
914
914
msg = "will attempt to set the values inplace instead"
915
915
with tm .assert_produces_warning (warn , match = msg ):
@@ -1425,7 +1425,7 @@ def test_loc_setitem_single_row_categorical(self):
1425
1425
categories = Categorical (df ["Alpha" ], categories = ["a" , "b" , "c" ])
1426
1426
1427
1427
msg = "will attempt to set the values inplace instead"
1428
- with tm .assert_produces_warning (FutureWarning , match = msg ):
1428
+ with tm .assert_produces_warning (DeprecationWarning , match = msg ):
1429
1429
df .loc [:, "Alpha" ] = categories
1430
1430
1431
1431
result = df ["Alpha" ]
@@ -3211,3 +3211,11 @@ def test_getitem_loc_str_periodindex(self):
3211
3211
index = pd .period_range (start = "2000" , periods = 20 , freq = "B" )
3212
3212
series = Series (range (20 ), index = index )
3213
3213
assert series .loc ["2000-01-14" ] == 9
3214
+
3215
+ def test_deprecation_warnings_raised_loc (self ):
3216
+ # GH#48673
3217
+ with tm .assert_produces_warning (DeprecationWarning ):
3218
+ values = np .arange (4 ).reshape (2 , 2 )
3219
+ df = DataFrame (values , columns = ["a" , "b" ])
3220
+ new = np .array ([10 , 11 ]).astype (np .int16 )
3221
+ df .loc [:, "a" ] = new
0 commit comments