MCPcopy
hub / github.com/pandas-dev/pandas / from_breaks

Method from_breaks

pandas/core/arrays/interval.py:486–528  ·  view source on GitHub ↗

Construct an IntervalArray from an array of splits. Parameters ---------- breaks : array-like (1-dimensional) Left and right bounds for each interval. closed : {'left', 'right', 'both', 'neither'}, default 'right' Whether the interval

(
        cls,
        breaks,
        closed: IntervalClosedType | None = "right",
        copy: bool = False,
        dtype: Dtype | None = None,
    )

Source from the content-addressed store, hash-verified

484
485 @classmethod
486 def from_breaks(
487 cls,
488 breaks,
489 closed: IntervalClosedType | None = "right",
490 copy: bool = False,
491 dtype: Dtype | None = None,
492 ) -> Self:
493 """
494 Construct an IntervalArray from an array of splits.
495
496 Parameters
497 ----------
498 breaks : array-like (1-dimensional)
499 Left and right bounds for each interval.
500 closed : {'left', 'right', 'both', 'neither'}, default 'right'
501 Whether the intervals are closed on the left-side, right-side, both
502 or neither.
503 copy : bool, default False
504 Copy the data.
505 dtype : dtype or None, default None
506 If None, dtype will be inferred.
507
508 Returns
509 -------
510 IntervalArray
511
512 See Also
513 --------
514 interval_range : Function to create a fixed frequency IntervalIndex.
515 IntervalArray.from_arrays : Construct from a left and right array.
516 IntervalArray.from_tuples : Construct from a sequence of tuples.
517
518 Examples
519 --------
520 >>> pd.arrays.IntervalArray.from_breaks([0, 1, 2, 3])
521 <IntervalArray>
522 [(0, 1], (1, 2], (2, 3]]
523 Length: 3, dtype: interval[int64, right]
524 """
525
526 breaks = _maybe_convert_platform_interval(breaks)
527
528 return cls.from_arrays(breaks[:-1], breaks[1:], closed, copy=copy, dtype=dtype)
529
530 _interval_shared_docs["from_arrays"] = textwrap.dedent(
531 """

Callers 15

setupMethod · 0.45
setupMethod · 0.45
setup_cacheMethod · 0.45
conftest.pyFile · 0.45
shiftMethod · 0.45
_format_labelsFunction · 0.45
test_value_countsMethod · 0.45

Calls 2

from_arraysMethod · 0.45