diff --git a/modin/core/storage_formats/pandas/query_compiler.py b/modin/core/storage_formats/pandas/query_compiler.py index cf4e0c1aaf7..cbe41184d00 100644 --- a/modin/core/storage_formats/pandas/query_compiler.py +++ b/modin/core/storage_formats/pandas/query_compiler.py @@ -4241,7 +4241,16 @@ def iloc_mut(partition, row_internal_indices, col_internal_indices, item): Partition data with updated values. """ partition = partition.copy() - partition.iloc[row_internal_indices, col_internal_indices] = item + try: + partition.iloc[row_internal_indices, col_internal_indices] = item + except ValueError: + # `copy` is needed to avoid "ValueError: buffer source array is read-only" for `item` + # because the item may be converted to the type that is in the dataframe. + # TODO: in the future we will need to convert to the correct type manually according + # to the following warning. Example: "FutureWarning: Setting an item of incompatible + # dtype is deprecated and will raise in a future error of pandas. Value '[1.38629436]' + # has dtype incompatible with int64, please explicitly cast to a compatible dtype first." + partition.iloc[row_internal_indices, col_internal_indices] = item.copy() return partition new_modin_frame = self._modin_frame.apply_select_indices( diff --git a/modin/numpy/test/utils.py b/modin/numpy/test/utils.py index 5e378f4ede7..8b32ae6dac4 100644 --- a/modin/numpy/test/utils.py +++ b/modin/numpy/test/utils.py @@ -16,7 +16,7 @@ import modin.numpy as np -def assert_scalar_or_array_equal(x1, x2, err_msg=None): +def assert_scalar_or_array_equal(x1, x2, err_msg=""): """ Assert whether the result of the numpy and modin computations are the same.