cast_to_common_type#

pandas_utils.utility.cast_to_common_type(x1, x2)#

Cast two objects to the same datatype.

The passed in objects must have the dtype attribute, and a call to astype(new_type) must return a copy of the object as new_type. Most, if not all, pandas objects meet this criteria.

Parameters:
  • x1 (_U) – The first object to cast the type of.

  • x2 (_V) – The second object to cast the type of.

Returns:

  • cast_x1x1 cast to a common type, as defined by np.promote_types(x1.dtype, x2.dtype)

  • cast_x2x2 cast to a common type, as defined by np.promote_types(x1.dtype, x2.dtype)

Return type:

tuple[_U, _V]