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

Class PeriodArray

pandas/core/arrays/period.py:127–1159  ·  view source on GitHub ↗

Pandas ExtensionArray for storing Period data. Users should use :func:`~pandas.array` to create new instances. Parameters ---------- values : Union[PeriodArray, Series[period], ndarray[int], PeriodIndex] The data to store. These should be arrays that can be directly

Source from the content-addressed store, hash-verified

125# error: Definition of "_concat_same_type" in base class "NDArrayBacked" is
126# incompatible with definition in base class "ExtensionArray"
127class PeriodArray(dtl.DatelikeOps, libperiod.PeriodMixin): # type: ignore[misc]
128 """
129 Pandas ExtensionArray for storing Period data.
130
131 Users should use :func:`~pandas.array` to create new instances.
132
133 Parameters
134 ----------
135 values : Union[PeriodArray, Series[period], ndarray[int], PeriodIndex]
136 The data to store. These should be arrays that can be directly
137 converted to ordinals without inference or copy (PeriodArray,
138 ndarray[int64]), or a box around such an array (Series[period],
139 PeriodIndex).
140 dtype : PeriodDtype, optional
141 A PeriodDtype instance from which to extract a `freq`. If both
142 `freq` and `dtype` are specified, then the frequencies must match.
143 copy : bool, default False
144 Whether to copy the ordinals before storing.
145
146 Attributes
147 ----------
148 None
149
150 Methods
151 -------
152 None
153
154 See Also
155 --------
156 Period: Represents a period of time.
157 PeriodIndex : Immutable Index for period data.
158 period_range: Create a fixed-frequency PeriodArray.
159 array: Construct a pandas array.
160
161 Notes
162 -----
163 There are two components to a PeriodArray
164
165 - ordinals : integer ndarray
166 - freq : pd.tseries.offsets.Offset
167
168 The values are physically stored as a 1-D ndarray of integers. These are
169 called "ordinals" and represent some kind of offset from a base.
170
171 The `freq` indicates the span covered by each element of the array.
172 All elements in the PeriodArray have the same `freq`.
173
174 Examples
175 --------
176 >>> pd.arrays.PeriodArray(pd.PeriodIndex(["2023-01-01", "2023-01-02"], freq="D"))
177 <PeriodArray>
178 ['2023-01-01', '2023-01-02']
179 Length: 2, dtype: period[D]
180 """
181
182 # array priority higher than numpy scalars
183 __array_priority__ = 1000
184 _typ = "periodarray" # ABCPeriodArray

Callers 15

_add_periodMethod · 0.90
_new_PeriodIndexFunction · 0.90
period_rangeFunction · 0.90
_get_valuesMethod · 0.90
__from_arrow__Method · 0.90
test_takeMethod · 0.90
test_strftime_natMethod · 0.90
test_setitemFunction · 0.90
test_setitem_raises_typeFunction · 0.90
test_arrow_array_missingFunction · 0.90

Calls 1

_field_accessorFunction · 0.70