pyarrow.month_interval#
- pyarrow.month_interval()#
Create instance of an interval type representing months between two dates.
Examples
Create an instance of a month_interval type:
>>> import pyarrow as pa >>> pa.month_interval() DataType(month_interval)
The type can’t be created from Python values yet, but compute functions return it:
>>> import pyarrow as pa >>> import pyarrow.compute as pc >>> import datetime >>> arr1 = pa.array([datetime.datetime(2020, 1, 1)], type=pa.timestamp('s')) >>> arr2 = pa.array([datetime.datetime(2020, 5, 5)], type=pa.timestamp('s'))
Create an array with month_interval type:
>>> pc.month_interval_between(arr1, arr2) <pyarrow.lib.MonthIntervalArray object at ...> [ 4M ]
or select a scalar with the same type:
>>> pc.month_interval_between(arr1, arr2)[0] <pyarrow.MonthIntervalScalar: Month(months=4)>