Ejemplo n.º 1
0
 def from_arrays(
     cls,
     left,
     right,
     closed: str = "right",
     name=None,
     copy: bool = False,
     dtype: Optional[Dtype] = None,
 ):
     with rewrite_exception("IntervalArray", cls.__name__):
         array = IntervalArray.from_arrays(left,
                                           right,
                                           closed,
                                           copy=copy,
                                           dtype=dtype)
     return cls._simple_new(array, name=name)
Ejemplo n.º 2
0
    def from_arrays(
        cls,
        left,
        right,
        inclusive: IntervalInclusiveType | None = None,
        name: Hashable = None,
        copy: bool = False,
        dtype: Dtype | None = None,
    ) -> IntervalIndex:

        if inclusive is None:
            inclusive = "right"

        with rewrite_exception("IntervalArray", cls.__name__):
            array = IntervalArray.from_arrays(left,
                                              right,
                                              inclusive,
                                              copy=copy,
                                              dtype=dtype)
        return cls._simple_new(array, name=name)
Ejemplo n.º 3
0
    def from_arrays(
        cls,
        left,
        right,
        inclusive=None,
        closed: None | lib.NoDefault = lib.no_default,
        name: Hashable = None,
        copy: bool = False,
        dtype: Dtype | None = None,
    ) -> IntervalIndex:

        inclusive, closed = _warning_interval(inclusive, closed)
        if inclusive is None:
            inclusive = "both"

        with rewrite_exception("IntervalArray", cls.__name__):
            array = IntervalArray.from_arrays(
                left, right, inclusive, copy=copy, dtype=dtype
            )
        return cls._simple_new(array, name=name)
Ejemplo n.º 4
0
    def insert(self, loc, item):
        """
        Return a new IntervalIndex inserting new item at location. Follows
        Python list.append semantics for negative values.  Only Interval
        objects and NA can be inserted into an IntervalIndex

        Parameters
        ----------
        loc : int
        item : object

        Returns
        -------
        IntervalIndex
        """
        left_insert, right_insert = self._data._validate_insert_value(item)

        new_left = self.left.insert(loc, left_insert)
        new_right = self.right.insert(loc, right_insert)
        result = IntervalArray.from_arrays(new_left, new_right, closed=self.closed)
        return self._shallow_copy(result)
Ejemplo n.º 5
0
 def from_arrays(cls, left, right, closed='right', name=None, copy=False,
                 dtype=None):
     with rewrite_exception("IntervalArray", cls.__name__):
         array = IntervalArray.from_arrays(left, right, closed, copy=copy,
                                           dtype=dtype)
     return cls._simple_new(array, name=name)