@@ -54,6 +54,8 @@ class ListDtype(ArrowDtype):
5454 An ExtensionDtype suitable for storing homogeneous lists of data.
5555 """
5656
57+ _is_immutable = True # TODO(wayd): should we allow mutability?
58+
5759 def __init__ (self , value_dtype : pa .DataType ) -> None :
5860 super ().__init__ (pa .large_list (value_dtype ))
5961
@@ -211,3 +213,19 @@ def astype(self, dtype: AstypeArg, copy: bool = True) -> ArrayLike:
211213 return np .array ([str (x ) for x in self ], dtype = dtype )
212214
213215 return super ().astype (dtype , copy )
216+
217+ def __eq__ (self , other ):
218+ if isinstance (other , (pa .ListScalar , pa .LargeListScalar )):
219+ from pandas .arrays import BooleanArray
220+
221+ # TODO: pyarrow.compute does not implement broadcasting equality
222+ # for an array of lists to a listscalar
223+ # TODO: pyarrow doesn't compare missing values as missing???
224+ # arr = pa.array([1, 2, None])
225+ # pc.equal(arr, arr[2]) returns all nulls but
226+ # arr[2] == arr[2] returns True
227+ mask = np .array ([False ] * len (self ))
228+ values = np .array ([x == other for x in self ._pa_array ])
229+ return BooleanArray (values , mask )
230+
231+ return super ().__eq__ (other )
0 commit comments