File tree 1 file changed +15
-0
lines changed
pandas/tests/series/methods
1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -675,3 +675,18 @@ def test_replace_value_none_dtype_numeric(self, val):
675
675
result = ser .replace (val , None )
676
676
expected = pd .Series ([1 , None ], dtype = object )
677
677
tm .assert_series_equal (result , expected )
678
+
679
+ def test_replace_change_dtype_series (self ):
680
+ # GH#25797
681
+ df = pd .DataFrame .from_dict ({"Test" : ["0.5" , True , "0.6" ]})
682
+ df ["Test" ] = df ["Test" ].replace ([True ], [np .nan ])
683
+ expected = pd .DataFrame .from_dict ({"Test" : ["0.5" , np .nan , "0.6" ]})
684
+ tm .assert_frame_equal (df , expected )
685
+
686
+ df = pd .DataFrame .from_dict ({"Test" : ["0.5" , None , "0.6" ]})
687
+ df ["Test" ] = df ["Test" ].replace ([None ], [np .nan ])
688
+ tm .assert_frame_equal (df , expected )
689
+
690
+ df = pd .DataFrame .from_dict ({"Test" : ["0.5" , None , "0.6" ]})
691
+ df ["Test" ] = df ["Test" ].fillna (np .nan )
692
+ tm .assert_frame_equal (df , expected )
You can’t perform that action at this time.
0 commit comments