@@ -1201,23 +1201,27 @@ def _maybe_coerce_merge_keys(self) -> None:
12011201
12021202 # check whether ints and floats
12031203 elif is_integer_dtype (rk .dtype ) and is_float_dtype (lk .dtype ):
1204- if not (lk == lk .astype (rk .dtype ))[~ np .isnan (lk )].all ():
1205- warnings .warn (
1206- "You are merging on int and float "
1207- "columns where the float values "
1208- "are not equal to their int representation." ,
1209- UserWarning ,
1210- )
1204+ # GH 47391 numpy > 1.24 will raise a RuntimeError for nan -> int
1205+ with np .errstate (invalid = "ignore" ):
1206+ if not (lk == lk .astype (rk .dtype ))[~ np .isnan (lk )].all ():
1207+ warnings .warn (
1208+ "You are merging on int and float "
1209+ "columns where the float values "
1210+ "are not equal to their int representation." ,
1211+ UserWarning ,
1212+ )
12111213 continue
12121214
12131215 elif is_float_dtype (rk .dtype ) and is_integer_dtype (lk .dtype ):
1214- if not (rk == rk .astype (lk .dtype ))[~ np .isnan (rk )].all ():
1215- warnings .warn (
1216- "You are merging on int and float "
1217- "columns where the float values "
1218- "are not equal to their int representation." ,
1219- UserWarning ,
1220- )
1216+ # GH 47391 numpy > 1.24 will raise a RuntimeError for nan -> int
1217+ with np .errstate (invalid = "ignore" ):
1218+ if not (rk == rk .astype (lk .dtype ))[~ np .isnan (rk )].all ():
1219+ warnings .warn (
1220+ "You are merging on int and float "
1221+ "columns where the float values "
1222+ "are not equal to their int representation." ,
1223+ UserWarning ,
1224+ )
12211225 continue
12221226
12231227 # let's infer and see if we are ok
0 commit comments