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

Method array

pandas/core/indexes/base.py:5024–5099  ·  view source on GitHub ↗

The ExtensionArray of the data backing this Index. This property provides direct access to the underlying array data of an Index without requiring conversion to a NumPy array. It returns an ExtensionArray, which is the native storage format for pandas extens

(self)

Source from the content-addressed store, hash-verified

5022
5023 @cache_readonly
5024 def array(self) -> ExtensionArray:
5025 """
5026 The ExtensionArray of the data backing this Index.
5027
5028 This property provides direct access to the underlying array data of
5029 an Index without requiring conversion to a NumPy array. It
5030 returns an ExtensionArray, which is the native storage format for
5031 pandas extension dtypes.
5032
5033 Returns
5034 -------
5035 ExtensionArray
5036 An ExtensionArray of the values stored within. For extension
5037 types, this is the actual array. For NumPy native types, this
5038 is a thin (no copy) wrapper around :class:`numpy.ndarray`.
5039
5040 ``.array`` differs from ``.values``, which may require converting
5041 the data to a different form.
5042
5043 See Also
5044 --------
5045 Index.to_numpy : Similar method that always returns a NumPy array.
5046 Series.to_numpy : Similar method that always returns a NumPy array.
5047
5048 Notes
5049 -----
5050 This table lays out the different array types for each extension
5051 dtype within pandas.
5052
5053 ================== =============================
5054 dtype array type
5055 ================== =============================
5056 category Categorical
5057 period PeriodArray
5058 interval IntervalArray
5059 IntegerNA IntegerArray
5060 string StringArray
5061 boolean BooleanArray
5062 datetime64[ns, tz] DatetimeArray
5063 ================== =============================
5064
5065 For any 3rd-party extension types, the array type will be an
5066 ExtensionArray.
5067
5068 For all remaining dtypes ``.array`` will be a
5069 :class:`arrays.NumpyExtensionArray` wrapping the actual ndarray
5070 stored within. If you absolutely need a NumPy array (possibly with
5071 copying / coercing data), then use :meth:`Series.to_numpy` instead.
5072
5073 Examples
5074 --------
5075 For regular NumPy types like int, and float, a NumpyExtensionArray
5076 is returned.
5077
5078 >>> pd.Index([1, 2, 3]).array
5079 <NumpyExtensionArray>
5080 [1, 2, 3]
5081 Length: 3, dtype: int64

Callers 15

_str_mapMethod · 0.45
_wrap_resultMethod · 0.45
catMethod · 0.45
_get_group_namesFunction · 0.45
_convert_listlikeFunction · 0.45
to_timeFunction · 0.45
_maybe_cacheFunction · 0.45
to_datetimeFunction · 0.45
_convert_listlikeFunction · 0.45
to_numericFunction · 0.45
_fill_zerosFunction · 0.45

Calls 1

NumpyExtensionArrayClass · 0.90

Tested by

no test coverage detected