Closed
Description
We are running into this in the pyarrow test suite. Reproducer on current main:
empty_list_array1 = np.empty((3,), dtype=object)
empty_list_array1.fill([])
df1 = pd.DataFrame({'a': empty_list_array1})
empty_list_array2 = np.empty((3,), dtype=object)
empty_list_array2.fill(np.array([], dtype=object))
df2 = pd.DataFrame({'a': empty_list_array2})
import warnings
warnings.simplefilter("always")
gives:
>>> pd.testing.assert_frame_equal(df1, df2)
/pandas/core/dtypes/missing.py:503: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.
return lib.array_equivalent_object(left, right)
The above is with numpy 1.26 and pandas main, but also see the same with latest numpy and pandas (2.1.1 and 2.2.2).