2727from  pandas .compat .numpy  import  function  as  nv 
2828from  pandas .util ._decorators  import  (
2929    cache_readonly ,
30-     doc ,
3130    set_module ,
3231)
3332
@@ -473,8 +472,51 @@ def inferred_type(self) -> str:
473472    # -------------------------------------------------------------------- 
474473    # Indexing Methods 
475474
476-     @doc (Index .get_loc ) 
477475    def  get_loc (self , key ) ->  int :
476+         """ 
477+         Get integer location for requested label. 
478+ 
479+         Parameters 
480+         ---------- 
481+         key : int or float 
482+             Label to locate. Integer-like floats (e.g. 3.0) are accepted and 
483+             treated as the corresponding integer. Non-integer floats and other 
484+             non-integer labels are not valid and will raise KeyError or 
485+             InvalidIndexError. 
486+ 
487+         Returns 
488+         ------- 
489+         int 
490+             Integer location of the label within the RangeIndex. 
491+ 
492+         Raises 
493+         ------ 
494+         KeyError 
495+             If the label is not present in the RangeIndex or the label is a 
496+             non-integer value. 
497+         InvalidIndexError 
498+             If the label is of an invalid type for the RangeIndex. 
499+ 
500+         See Also 
501+         -------- 
502+         RangeIndex.get_slice_bound : Calculate slice bound that corresponds to 
503+             given label. 
504+         RangeIndex.get_indexer : Computes indexer and mask for new index given 
505+             the current index. 
506+         RangeIndex.get_non_unique : Returns indexer and masks for new index given 
507+             the current index. 
508+         RangeIndex.get_indexer_for : Returns an indexer even when non-unique. 
509+ 
510+         Examples 
511+         -------- 
512+         >>> idx = pd.RangeIndex(5) 
513+         >>> idx.get_loc(3) 
514+         3 
515+ 
516+         >>> idx = pd.RangeIndex(2, 10, 2)  # values [2, 4, 6, 8] 
517+         >>> idx.get_loc(6) 
518+         2 
519+         """ 
478520        if  is_integer (key ) or  (is_float (key ) and  key .is_integer ()):
479521            new_key  =  int (key )
480522            try :
@@ -528,12 +570,39 @@ def _should_fallback_to_positional(self) -> bool:
528570    def  tolist (self ) ->  list [int ]:
529571        return  list (self ._range )
530572
531-     @doc (Index .__iter__ ) 
532573    def  __iter__ (self ) ->  Iterator [int ]:
574+         """ 
575+         Return an iterator of the values. 
576+ 
577+         Returns 
578+         ------- 
579+         iterator 
580+             An iterator yielding ints from the RangeIndex. 
581+ 
582+         Examples 
583+         -------- 
584+         >>> idx = pd.RangeIndex(3) 
585+         >>> for x in idx: 
586+         ...     print(x) 
587+         0 
588+         1 
589+         2 
590+         """ 
533591        yield  from  self ._range 
534592
535-     @doc (Index ._shallow_copy ) 
536593    def  _shallow_copy (self , values , name : Hashable  =  no_default ):
594+         """ 
595+         Create a new RangeIndex with the same class as the caller, don't copy the 
596+         data, use the same object attributes with passed in attributes taking 
597+         precedence. 
598+ 
599+         *this is an internal non-public method* 
600+ 
601+         Parameters 
602+         ---------- 
603+         values : the values to create the new RangeIndex, optional 
604+         name : Label, defaults to self.name 
605+         """ 
537606        name  =  self ._name  if  name  is  no_default  else  name 
538607
539608        if  values .dtype .kind  ==  "f" :
@@ -560,8 +629,42 @@ def _wrap_reindex_result(self, target, indexer, preserve_names: bool):
560629            target  =  self ._shallow_copy (target ._values , name = target .name )
561630        return  super ()._wrap_reindex_result (target , indexer , preserve_names )
562631
563-     @doc (Index .copy ) 
564632    def  copy (self , name : Hashable  |  None  =  None , deep : bool  =  False ) ->  Self :
633+         """ 
634+         Make a copy of this object. 
635+ 
636+         Name is set on the new object. 
637+ 
638+         Parameters 
639+         ---------- 
640+         name : Label, optional 
641+             Set name for new object. 
642+         deep : bool, default False 
643+             If True attempts to make a deep copy of the RangeIndex. 
644+                 Else makes a shallow copy. 
645+ 
646+         Returns 
647+         ------- 
648+         RangeIndex 
649+             RangeIndex refer to new object which is a copy of this object. 
650+ 
651+         See Also 
652+         -------- 
653+         RangeIndex.delete: Make new RangeIndex with passed location(-s) deleted. 
654+         RangeIndex.drop: Make new RangeIndex with passed list of labels deleted. 
655+ 
656+         Notes 
657+         ----- 
658+         In most cases, there should be no functional difference from using 
659+         ``deep``, but if ``deep`` is passed it will attempt to deepcopy. 
660+ 
661+         Examples 
662+         -------- 
663+         >>> idx = pd.RangeIndex(3) 
664+         >>> new_idx = idx.copy() 
665+         >>> idx is new_idx 
666+         False 
667+         """ 
565668        name  =  self ._validate_names (name = name , deep = deep )[0 ]
566669        new_index  =  self ._rename (name = name )
567670        return  new_index 
0 commit comments