@@ -675,7 +675,7 @@ def _is_key_type_compatible(self, key):
675675 # object kind can match anything
676676 return key_kind == label_kind or key_kind == 'O' or label_kind == 'O' or py2_str_match
677677
678- def translate (self , key , bool_passthrough = True ):
678+ def index (self , key , bool_passthrough = True ):
679679 """
680680 Translates a label key to its numerical index counterpart.
681681
@@ -698,9 +698,9 @@ def translate(self, key, bool_passthrough=True):
698698 Examples
699699 --------
700700 >>> people = Axis(['John Doe', 'Bruce Wayne', 'Bruce Willis', 'Waldo', 'Arthur Dent', 'Harvey Dent'], 'people')
701- >>> people.translate ('Waldo')
701+ >>> people.index ('Waldo')
702702 3
703- >>> people.translate (people.matching('Bruce'))
703+ >>> people.index (people.matching('Bruce'))
704704 array([1, 2])
705705 """
706706 mapping = self ._mapping
@@ -784,7 +784,7 @@ def translate(self, key, bool_passthrough=True):
784784 return array_lookup2 (key , self ._sorted_keys , self ._sorted_values )
785785 elif isinstance (key , ABCLArray ):
786786 from .array import LArray
787- return LArray (self .translate (key .data ), key .axes )
787+ return LArray (self .index (key .data ), key .axes )
788788 else :
789789 # the first mapping[key] above will cover most cases.
790790 # This code path is only used if the key was given in "non normalized form"
@@ -796,6 +796,8 @@ def translate(self, key, bool_passthrough=True):
796796 # print("diff dtype", )
797797 raise KeyError (key )
798798
799+ translate = renamed_to (index , 'translate' )
800+
799801 # FIXME: remove id
800802 @property
801803 def id (self ):
@@ -946,7 +948,7 @@ def replace(self, old, new=None):
946948 assert len (old ) == len (new )
947949 # using object dtype because new labels length can be larger than the fixed str length in the self.labels array
948950 labels = self .labels .astype (object )
949- indices = self .translate (old )
951+ indices = self .index (old )
950952 labels [indices ] = new
951953 return Axis (labels , self .name )
952954
@@ -1993,7 +1995,7 @@ def translate_full_key(self, key):
19931995 (slice(None, None, None), 1, 2)
19941996 """
19951997 assert len (key ) == len (self )
1996- return tuple (axis .translate (axis_key ) for axis_key , axis in zip (key , self ))
1998+ return tuple (axis .index (axis_key ) for axis_key , axis in zip (key , self ))
19971999
19982000 @property
19992001 def labels (self ):
@@ -2515,7 +2517,7 @@ def __init__(self, name):
25152517 self ._labels = None
25162518 self ._iswildcard = False
25172519
2518- def translate (self , key ):
2520+ def index (self , key ):
25192521 raise NotImplementedError ("an AxisReference (X.) cannot translate labels" )
25202522
25212523 def __repr__ (self ):
0 commit comments