pandas 1.4.2

ParametersReturnsBackRef
period_array(data: 'Sequence[Period | str | None] | AnyArrayLike', freq: 'str | Tick | None' = None, copy: 'bool' = False) -> 'PeriodArray'

Parameters

data : Sequence of Period objects

A sequence of Period objects. These are required to all have the same freq. Missing values can be indicated by None or pandas.NaT .

freq : str, Tick, or Offset

The frequency of every element of the array. This can be specified to avoid inferring the :None:None:`freq` from :None:None:`data`.

copy : bool, default False

Whether to ensure a copy of the data is made.

Returns

PeriodArray

Construct a new PeriodArray from a sequence of Period scalars.

See Also

PeriodArray
pandas.PeriodIndex

Examples

This example is valid syntax, but we were not able to check execution
>>> period_array([pd.Period('2017', freq='A'),
...  pd.Period('2018', freq='A')]) <PeriodArray> ['2017', '2018'] Length: 2, dtype: period[A-DEC]
This example is valid syntax, but we were not able to check execution
>>> period_array([pd.Period('2017', freq='A'),
...  pd.Period('2018', freq='A'),
...  pd.NaT]) <PeriodArray> ['2017', '2018', 'NaT'] Length: 3, dtype: period[A-DEC]

Integers that look like years are handled

This example is valid syntax, but we were not able to check execution
>>> period_array([2000, 2001, 2002], freq='D')
<PeriodArray>
['2000-01-01', '2001-01-01', '2002-01-01']
Length: 3, dtype: period[D]

Datetime-like strings may also be passed

This example is valid syntax, but we were not able to check execution
>>> period_array(['2000-Q1', '2000-Q2', '2000-Q3', '2000-Q4'], freq='Q')
<PeriodArray>
['2000Q1', '2000Q2', '2000Q3', '2000Q4']
Length: 4, dtype: period[Q-DEC]
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

pandas.core.arrays.period.period_array

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /pandas/core/arrays/period.py#963
type: <class 'function'>
Commit: