Pandas: Data Manipulation - interval_range() function

interval_range() function

The interval_range() function is used to concatenate pandas objects along a particular axis with optional set logic along the other axes.


pandas.interval_range(start=None, end=None, periods=None, freq=None, name=None, closed='right')

Return a fixed frequency IntervalIndex


Name Description Type Default Value Required / Optional
start  Left bound for generating intervals numeric or datetime-like None Required
end  Right bound for generating intervals numeric or datetime-like None Required
periods Number of periods to generate integer None Required
freq The length of each interval. Must be consistent with the type of start and end, e.g. 2 for numeric, or ‘5H’ for datetime-like. Default is 1 for numeric and ‘D’ for datetime-like. numeric, string, or DateOffset None Required
name Name of the resulting IntervalIndex string None Required
closed  Whether the intervals are closed on the left-side, right-side, both or neither. {‘left’, ‘right’, ‘both’, ‘neither’} ‘right’ Required

Returns: rng- IntervalIndex


Of the four parameters start, end, periods, and freq, exactly three must be specified. If freq is omitted, the resulting IntervalIndex will have periods linearly spaced elements between start and end, inclusively.


Download the above Notebook from here.

Previous: timedelta_range() function
Next: eval() function