@@ -178,11 +178,31 @@ def test_update_dt_column_with_NaT_create_column(self):
178
178
)
179
179
tm .assert_frame_equal (df , expected )
180
180
181
- def test_update_preserve_column_dtype_bool (self ):
181
+ @pytest .mark .parametrize (
182
+ "value_df, value_other, dtype" ,
183
+ [
184
+ (True , False , bool ),
185
+ (1 , 2 , int ),
186
+ (np .uint64 (1 ), np .uint (2 ), np .dtype ("uint64" )),
187
+ (1.0 , 2.0 , float ),
188
+ (1.0 + 1j , 2.0 + 2j , complex ),
189
+ ("a" , "b" , pd .StringDtype ()),
190
+ (
191
+ pd .to_timedelta ("1 ms" ),
192
+ pd .to_timedelta ("2 ms" ),
193
+ np .dtype ("timedelta64[ns]" ),
194
+ ),
195
+ (
196
+ np .datetime64 ("2000-01-01T00:00:00" ),
197
+ np .datetime64 ("2000-01-02T00:00:00" ),
198
+ np .dtype ("datetime64[ns]" ),
199
+ ),
200
+ ],
201
+ )
202
+ def test_update_preserve_dtype (self , value_df , value_other , dtype ):
182
203
# GH#55509
183
- df = DataFrame ({"A " : [True , True ] }, index = [1 , 2 ])
184
- other = DataFrame ({"A " : [False ]}, index = [1 ])
185
- expected = DataFrame ({"A " : [False , True ]}, index = [1 , 2 ])
204
+ df = DataFrame ({"a " : [value_df ] * 2 }, index = [1 , 2 ])
205
+ other = DataFrame ({"a " : [value_other ]}, index = [1 ])
206
+ expected = DataFrame ({"a " : [value_other , value_df ]}, index = [1 , 2 ])
186
207
df .update (other )
187
-
188
208
tm .assert_frame_equal (df , expected )
0 commit comments