@@ -78,6 +78,7 @@ class ExtensionArray:
78
78
dropna
79
79
factorize
80
80
fillna
81
+ equals
81
82
isna
82
83
ravel
83
84
repeat
@@ -350,6 +351,38 @@ def __iter__(self):
350
351
for i in range (len (self )):
351
352
yield self [i ]
352
353
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
+
353
386
# ------------------------------------------------------------------------
354
387
# Required attributes
355
388
# ------------------------------------------------------------------------
@@ -657,6 +690,23 @@ def searchsorted(self, value, side="left", sorter=None):
657
690
arr = self .astype (object )
658
691
return arr .searchsorted (value , side = side , sorter = sorter )
659
692
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
+
660
710
def _values_for_factorize (self ) -> Tuple [np .ndarray , Any ]:
661
711
"""
662
712
Return an array and missing value suitable for factorization.
0 commit comments