pandas-dev/pandas · error · TypeError
Not supported to convert PeriodArray to
Error message
Not supported to convert PeriodArray to '{type}' type What it means
Raised by PeriodArray.__arrow_array__ when the target pyarrow type is neither an integer type nor an ArrowPeriodType. Period data can only be exported to arrow as raw int64 ordinals or as a proper period extension type; other types (string, timestamp, float, list, etc.) are not supported and would lose semantics.
Solutions
- Omit the type argument and let pandas infer ArrowPeriodType.
- Specify an integer type if you want raw ordinals: pa.array(period_idx, type=pa.int64()).
- If a timestamp/string representation is required, convert in pandas first (.to_timestamp() or .astype(str)) then export.
Example fix
# before
pa.array(period_idx, type=pa.timestamp('ns')) # raises
# after
pa.array(period_idx.to_timestamp()) Defensive patterns
Strategy: validation
Validate before calling
import pyarrow as pa
from pandas.core.arrays.arrow.extension_types import ArrowPeriodType
def supported_arrow_type_for_period(target_type):
if target_type is None:
return True
if pa.types.is_integer(target_type):
return True
return isinstance(target_type, ArrowPeriodType) Type guard
def is_supported_period_arrow_type(target_type) -> bool:
import pyarrow as pa
from pandas.core.arrays.arrow.extension_types import ArrowPeriodType
return (target_type is None or pa.types.is_integer(target_type)
or isinstance(target_type, ArrowPeriodType)) Try / catch
try:
pa.array(period_idx, type=target_type)
except TypeError as e:
if 'Not supported to convert' in str(e):
pa.array(period_idx.to_timestamp()) # or omit type
else:
raise Prevention
- Omit the pyarrow type argument to let pandas pick ArrowPeriodType automatically.
- For raw ordinals, use pa.int64(); for timestamps, convert via .to_timestamp() first.
- Validate the schema's period-column type in from_pandas pipelines.
When it happens
Trigger: pa.array(period_idx, type=pa.string()). pa.array(period_idx, type=pa.timestamp('ns')). pyarrow.Table.from_pandas with a schema that declares the period column as a non-integer/period type.
Common situations: Schema mismatches in from_pandas/to_pandas round-trips; assuming period maps to arrow timestamp; user-built pyarrow schemas.
Related errors
- Not supported to convert PeriodArray to array with…
- ArrowStringArray requires a PyArrow (chunked) array of…
- Cannot add or subtract timedelta64[ns] dtype from
- Cannot add/subtract timedelta-like from PeriodArray that is…
- cannot convert float NaN to integer
AI-assisted analysis of pandas-dev/pandas@3b7651241d (2026-08-11).
Data as JSON: /api/errors/eff81327dbd244db.
Report an issue: GitHub.
Appendix: source
Thrown at pandas/core/arrays/period.py:491
"""
Convert myself into a pyarrow Array.
"""
import pyarrow
from pandas.core.arrays.arrow.extension_types import ArrowPeriodType
if type is not None:
if pyarrow.types.is_integer(type):
return pyarrow.array(self._ndarray, mask=self.isna(), type=type)
elif isinstance(type, ArrowPeriodType):
# ensure we have the same freq
if self.freqstr != type.freq:
raise TypeError(
"Not supported to convert PeriodArray to array with different "
f"'freq' ({self.freqstr} vs {type.freq})"
)
else:
raise TypeError(
f"Not supported to convert PeriodArray to '{type}' type"
)
period_type = ArrowPeriodType(self.freqstr)
storage_array = pyarrow.array(self._ndarray, mask=self.isna(), type="int64")
return pyarrow.ExtensionArray.from_storage(period_type, storage_array)
# --------------------------------------------------------------------
# Vectorized analogues of Period properties
year = _field_accessor(
"year",
"""
The year of the period.
Returns the year component for each period in the index.
See AlsoView on GitHub (pinned to 3b7651241d)