code: def period_array(data, freq=None, copy=False):
      # type: (Sequence[Optional[Period]], Optional[Tick], bool) -> PeriodArray
      """
      Construct a new PeriodArray from a sequence of Period scalars.
  
      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 `freq` from `data`.
      copy : bool, default False
          Whether to ensure a copy of the data is made.
  
      Returns
      -------
      PeriodArray
  
      See Also
      --------
      PeriodArray
      pandas.PeriodIndex
  
      Examples
      --------
      >>> period_array([pd.Period('2017', freq='A'),
      ...               pd.Period('2018', freq='A')])
      <PeriodArray>
      ['2017', '2018']
      Length: 2, dtype: period[A-DEC]
  
      >>> 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
  
      >>> period_array([2000, 2001, 2002], freq='D')
      ['2000-01-01', '2001-01-01', '2002-01-01']
      Length: 3, dtype: period[D]
  
      Datetime-like strings may also be passed
  
      >>> period_array(['2000-Q1', '2000-Q2', '2000-Q3', '2000-Q4'], freq='Q')
      <PeriodArray>
      ['2000Q1', '2000Q2', '2000Q3', '2000Q4']
      Length: 4, dtype: period[Q-DEC]
      """
      if is_datetime64_dtype(data):
          return PeriodArray._from_datetime64(data, freq)
      if isinstance(data, (ABCPeriodIndex, ABCSeries, PeriodArray)):
          return PeriodArray(data, freq)
  
      # other iterable of some kind
      if not isinstance(data, (np.ndarray, list, tuple)):
          data = list(data)
  
      data = np.asarray(data)
  
      if freq:
          dtype = PeriodDtype(freq)
      else:
          dtype = None
  
      if is_float_dtype(data) and len(data) > 0:
          raise TypeError(
              "PeriodIndex does not allow "
              "floating point in construction"
          )
  
      data = ensure_object(data)
  
      return PeriodArray._from_sequence(data, dtype=dtype)
  
imports: from datetime import timedelta
  import operator
  import numpy
  from pandas._libs.tslibs import NaT, frequencies, iNaT, period
  from pandas._libs.tslibs.fields import isleapyear_arr
  from pandas._libs.tslibs.period import DIFFERENT_FREQ, IncompatibleFrequency, Period, get_period_field_arr, period_asfreq_arr
  from pandas._libs.tslibs.timedeltas import Timedelta, delta_to_nanoseconds
  import pandas.compat
  from pandas.util._decorators import Appender, cache_readonly
  from pandas.core.dtypes.common import _TD_DTYPE, ensure_object, is_datetime64_dtype, is_float_dtype, is_list_like, is_period_dtype, pandas_dtype
  from pandas.core.dtypes.dtypes import PeriodDtype
  from pandas.core.dtypes.generic import ABCDataFrame, ABCIndexClass, ABCPeriodIndex, ABCSeries
  from pandas.core.dtypes.missing import isna, notna
  import pandas.core.algorithms
  from pandas.core.arrays import datetimelike
  import pandas.core.common
  from pandas.tseries import frequencies
  from pandas.tseries.offsets import DateOffset, Tick, _delta_to_tick
label_desc: Use image node_id 4 for calling a global function with example usage: period_array(data, freq, copy) and returns: PeriodArray, PeriodArray, PeriodArray