MCPcopy
hub / github.com/pandas-dev/pandas / set_axis

Method set_axis

pandas/core/generic.py:680–725  ·  view source on GitHub ↗

Assign desired index to given axis. Indexes for%(extended_summary_sub)s row labels can be changed by assigning a list-like or Index. Parameters ---------- labels : list-like, Index The values for the new index. axis : %(axes_sin

(
        self,
        labels,
        *,
        axis: Axis = 0,
        copy: bool | lib.NoDefault = lib.no_default,
    )

Source from the content-addressed store, hash-verified

678 return int(np.prod(self.shape))
679
680 def set_axis(
681 self,
682 labels,
683 *,
684 axis: Axis = 0,
685 copy: bool | lib.NoDefault = lib.no_default,
686 ) -> Self:
687 """
688 Assign desired index to given axis.
689
690 Indexes for%(extended_summary_sub)s row labels can be changed by assigning
691 a list-like or Index.
692
693 Parameters
694 ----------
695 labels : list-like, Index
696 The values for the new index.
697
698 axis : %(axes_single_arg)s, default 0
699 The axis to update. The value 0 identifies the rows. For `Series`
700 this parameter is unused and defaults to 0.
701
702 copy : bool, default False
703 This keyword is now ignored; changing its value will have no
704 impact on the method.
705
706 .. deprecated:: 3.0.0
707
708 This keyword is ignored and will be removed in pandas 4.0. Since
709 pandas 3.0, this method always returns a new object using a lazy
710 copy mechanism that defers copies until necessary
711 (Copy-on-Write). See the `user guide on Copy-on-Write
712 <https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
713 for more details.
714
715 Returns
716 -------
717 %(klass)s
718 An object of type %(klass)s.
719
720 See Also
721 --------
722 %(klass)s.rename_axis : Alter the name of the index%(see_also_sub)s.
723 """
724 self._check_copy_deprecation(copy)
725 return self._set_axis_nocheck(labels, axis, inplace=False)
726
727 @overload
728 def _set_axis_nocheck(

Callers 6

droplevelMethod · 0.95
_shift_with_freqMethod · 0.95
_set_axisMethod · 0.45
sort_indexMethod · 0.45
tz_convertMethod · 0.45
tz_localizeMethod · 0.45

Calls 2

_set_axis_nocheckMethod · 0.95

Tested by

no test coverage detected