@@ -78,6 +78,7 @@ class ExtensionArray:
7878 dropna
7979 factorize
8080 fillna
81+ equals
8182 isna
8283 ravel
8384 repeat
@@ -350,6 +351,38 @@ def __iter__(self):
350351 for i in range (len (self )):
351352 yield self [i ]
352353
354+ def __eq__ (self , other : ABCExtensionArray ) -> bool :
355+ """
356+ Whether the two arrays are equivalent.
357+
358+ Parameters
359+ ----------
360+ other: ExtensionArray
361+ The array to compare to this array.
362+
363+ Returns
364+ -------
365+ bool
366+ """
367+
368+ raise AbstractMethodError (self )
369+
370+ def __ne__ (self , other : ABCExtensionArray ) -> bool :
371+ """
372+ Whether the two arrays are not equivalent.
373+
374+ Parameters
375+ ----------
376+ other: ExtensionArray
377+ The array to compare to this array.
378+
379+ Returns
380+ -------
381+ bool
382+ """
383+
384+ raise AbstractMethodError (self )
385+
353386 # ------------------------------------------------------------------------
354387 # Required attributes
355388 # ------------------------------------------------------------------------
@@ -657,6 +690,23 @@ def searchsorted(self, value, side="left", sorter=None):
657690 arr = self .astype (object )
658691 return arr .searchsorted (value , side = side , sorter = sorter )
659692
693+ def equals (self , other : ABCExtensionArray ) -> bool :
694+ """
695+ Return if another array is equivalent to this array.
696+
697+ Parameters
698+ ----------
699+ other: ExtensionArray
700+ Array to compare to this Array.
701+
702+ Returns
703+ -------
704+ boolean
705+ Whether the arrays are equivalent.
706+
707+ """
708+ return ((self == other ) | (self .isna () == other .isna ())).all ()
709+
660710 def _values_for_factorize (self ) -> Tuple [np .ndarray , Any ]:
661711 """
662712 Return an array and missing value suitable for factorization.
0 commit comments