7272 Pandas4Warning ,
7373)
7474from pandas .util ._decorators import (
75- Appender ,
7675 cache_readonly ,
77- doc ,
7876 set_module ,
7977)
8078from pandas .util ._exceptions import (
@@ -5016,8 +5014,73 @@ def values(self) -> ArrayLike:
50165014 return data
50175015
50185016 @cache_readonly
5019- @doc (IndexOpsMixin .array )
50205017 def array (self ) -> ExtensionArray :
5018+ """
5019+ The ExtensionArray of the data backing this Series or Index.
5020+
5021+ This property provides direct access to the underlying array data of a
5022+ Series or Index without requiring conversion to a NumPy array. It
5023+ returns an ExtensionArray, which is the native storage format for
5024+ pandas extension dtypes.
5025+
5026+ Returns
5027+ -------
5028+ ExtensionArray
5029+ An ExtensionArray of the values stored within. For extension
5030+ types, this is the actual array. For NumPy native types, this
5031+ is a thin (no copy) wrapper around :class:`numpy.ndarray`.
5032+
5033+ ``.array`` differs from ``.values``, which may require converting
5034+ the data to a different form.
5035+
5036+ See Also
5037+ --------
5038+ Index.to_numpy : Similar method that always returns a NumPy array.
5039+ Series.to_numpy : Similar method that always returns a NumPy array.
5040+
5041+ Notes
5042+ -----
5043+ This table lays out the different array types for each extension
5044+ dtype within pandas.
5045+
5046+ ================== =============================
5047+ dtype array type
5048+ ================== =============================
5049+ category Categorical
5050+ period PeriodArray
5051+ interval IntervalArray
5052+ IntegerNA IntegerArray
5053+ string StringArray
5054+ boolean BooleanArray
5055+ datetime64[ns, tz] DatetimeArray
5056+ ================== =============================
5057+
5058+ For any 3rd-party extension types, the array type will be an
5059+ ExtensionArray.
5060+
5061+ For all remaining dtypes ``.array`` will be a
5062+ :class:`arrays.NumpyExtensionArray` wrapping the actual ndarray
5063+ stored within. If you absolutely need a NumPy array (possibly with
5064+ copying / coercing data), then use :meth:`Series.to_numpy` instead.
5065+
5066+ Examples
5067+ --------
5068+ For regular NumPy types like int, and float, a NumpyExtensionArray
5069+ is returned.
5070+
5071+ >>> pd.Series([1, 2, 3]).array
5072+ <NumpyExtensionArray>
5073+ [1, 2, 3]
5074+ Length: 3, dtype: int64
5075+
5076+ For extension types, like Categorical, the actual ExtensionArray
5077+ is returned
5078+
5079+ >>> ser = pd.Series(pd.Categorical(["a", "b", "a"]))
5080+ >>> ser.array
5081+ ['a', 'b', 'a']
5082+ Categories (2, str): ['a', 'b']
5083+ """
50215084 array = self ._data
50225085 if isinstance (array , np .ndarray ):
50235086 from pandas .core .arrays .numpy_ import NumpyExtensionArray
@@ -5123,8 +5186,37 @@ def _from_join_target(self, result: np.ndarray) -> ArrayLike:
51235186 return type (self .values )._from_sequence (result , dtype = self .dtype )
51245187 return result
51255188
5126- @doc (IndexOpsMixin ._memory_usage )
51275189 def memory_usage (self , deep : bool = False ) -> int :
5190+ """
5191+ Memory usage of the values.
5192+
5193+ Parameters
5194+ ----------
5195+ deep : bool, default False
5196+ Introspect the data deeply, interrogate
5197+ `object` dtypes for system-level memory consumption.
5198+
5199+ Returns
5200+ -------
5201+ bytes used
5202+ Returns memory usage of the values in the Index in bytes.
5203+
5204+ See Also
5205+ --------
5206+ numpy.ndarray.nbytes : Total bytes consumed by the elements of the
5207+ array.
5208+
5209+ Notes
5210+ -----
5211+ Memory usage does not include memory consumed by elements that
5212+ are not components of the array if deep=False or if used on PyPy
5213+
5214+ Examples
5215+ --------
5216+ >>> idx = pd.Index([1, 2, 3])
5217+ >>> idx.memory_usage()
5218+ 24
5219+ """
51285220 result = self ._memory_usage (deep = deep )
51295221
51305222 # include our engine hashtable, only if it's already cached
@@ -7443,10 +7535,67 @@ def _maybe_disable_logical_methods(self, opname: str_t) -> None:
74437535 if isinstance (self , ABCMultiIndex ):
74447536 raise TypeError (f"cannot perform { opname } with { type (self ).__name__ } " )
74457537
7446- @Appender (IndexOpsMixin .argmin .__doc__ )
74477538 def argmin (
74487539 self , axis : AxisInt | None = None , skipna : bool = True , * args , ** kwargs
74497540 ) -> int :
7541+ """
7542+ Return int position of the smallest value in the Series.
7543+
7544+ If the minimum is achieved in multiple locations,
7545+ the first row position is returned.
7546+
7547+ Parameters
7548+ ----------
7549+ axis : {None}
7550+ Unused. Parameter needed for compatibility with DataFrame.
7551+ skipna : bool, default True
7552+ Exclude NA/null values. If the entire Series is NA, or if ``skipna=False``
7553+ and there is an NA value, this method will raise a ``ValueError``.
7554+ *args, **kwargs
7555+ Additional arguments and keywords for compatibility with NumPy.
7556+
7557+ Returns
7558+ -------
7559+ int
7560+ Row position of the minimum value.
7561+
7562+ See Also
7563+ --------
7564+ Series.argmin : Return position of the minimum value.
7565+ Series.argmax : Return position of the maximum value.
7566+ numpy.ndarray.argmin : Equivalent method for numpy arrays.
7567+ Series.idxmax : Return index label of the maximum values.
7568+ Series.idxmin : Return index label of the minimum values.
7569+
7570+ Examples
7571+ --------
7572+ Consider dataset containing cereal calories
7573+
7574+ >>> s = pd.Series(
7575+ ... [100.0, 110.0, 120.0, 110.0],
7576+ ... index=[
7577+ ... "Corn Flakes",
7578+ ... "Almond Delight",
7579+ ... "Cinnamon Toast Crunch",
7580+ ... "Cocoa Puff",
7581+ ... ],
7582+ ... )
7583+ >>> s
7584+ Corn Flakes 100.0
7585+ Almond Delight 110.0
7586+ Cinnamon Toast Crunch 120.0
7587+ Cocoa Puff 110.0
7588+ dtype: float64
7589+
7590+ >>> s.argmax()
7591+ np.int64(2)
7592+ >>> s.argmin()
7593+ np.int64(0)
7594+
7595+ The maximum cereal calories is the third element and
7596+ the minimum cereal calories is the first element,
7597+ since series is zero-indexed.
7598+ """
74507599 nv .validate_argmin (args , kwargs )
74517600 nv .validate_minmax_axis (axis )
74527601
@@ -7458,10 +7607,67 @@ def argmin(
74587607
74597608 return super ().argmin (skipna = skipna )
74607609
7461- @Appender (IndexOpsMixin .argmax .__doc__ )
74627610 def argmax (
74637611 self , axis : AxisInt | None = None , skipna : bool = True , * args , ** kwargs
74647612 ) -> int :
7613+ """
7614+ Return int position of the largest value in the Series.
7615+
7616+ If the maximum is achieved in multiple locations,
7617+ the first row position is returned.
7618+
7619+ Parameters
7620+ ----------
7621+ axis : {None}
7622+ Unused. Parameter needed for compatibility with DataFrame.
7623+ skipna : bool, default True
7624+ Exclude NA/null values. If the entire Series is NA, or if ``skipna=False``
7625+ and there is an NA value, this method will raise a ``ValueError``.
7626+ *args, **kwargs
7627+ Additional arguments and keywords for compatibility with NumPy.
7628+
7629+ Returns
7630+ -------
7631+ int
7632+ Row position of the maximum value.
7633+
7634+ See Also
7635+ --------
7636+ Series.argmax : Return position of the maximum value.
7637+ Series.argmin : Return position of the minimum value.
7638+ numpy.ndarray.argmax : Equivalent method for numpy arrays.
7639+ Series.idxmax : Return index label of the maximum values.
7640+ Series.idxmin : Return index label of the minimum values.
7641+
7642+ Examples
7643+ --------
7644+ Consider dataset containing cereal calories
7645+
7646+ >>> s = pd.Series(
7647+ ... [100.0, 110.0, 120.0, 110.0],
7648+ ... index=[
7649+ ... "Corn Flakes",
7650+ ... "Almond Delight",
7651+ ... "Cinnamon Toast Crunch",
7652+ ... "Cocoa Puff",
7653+ ... ],
7654+ ... )
7655+ >>> s
7656+ Corn Flakes 100.0
7657+ Almond Delight 110.0
7658+ Cinnamon Toast Crunch 120.0
7659+ Cocoa Puff 110.0
7660+ dtype: float64
7661+
7662+ >>> s.argmax()
7663+ np.int64(2)
7664+ >>> s.argmin()
7665+ np.int64(0)
7666+
7667+ The maximum cereal calories is the third element and
7668+ the minimum cereal calories is the first element,
7669+ since series is zero-indexed.
7670+ """
74657671 nv .validate_argmax (args , kwargs )
74667672 nv .validate_minmax_axis (axis )
74677673
0 commit comments