Exemplo n.º 1
0
 def _coerce_to_array(self, values) -> Tuple[np.ndarray, np.ndarray]:
     raise AbstractMethodError(self)
Exemplo n.º 2
0
    def array(self) -> ExtensionArray:
        """
        The ExtensionArray of the data backing this Series or Index.

        Returns
        -------
        ExtensionArray
            An ExtensionArray of the values stored within. For extension
            types, this is the actual array. For NumPy native types, this
            is a thin (no copy) wrapper around :class:`numpy.ndarray`.

            ``.array`` differs ``.values`` which may require converting the
            data to a different form.

        See Also
        --------
        Index.to_numpy : Similar method that always returns a NumPy array.
        Series.to_numpy : Similar method that always returns a NumPy array.

        Notes
        -----
        This table lays out the different array types for each extension
        dtype within pandas.

        ================== =============================
        dtype              array type
        ================== =============================
        category           Categorical
        period             PeriodArray
        interval           IntervalArray
        IntegerNA          IntegerArray
        string             StringArray
        boolean            BooleanArray
        datetime64[ns, tz] DatetimeArray
        ================== =============================

        For any 3rd-party extension types, the array type will be an
        ExtensionArray.

        For all remaining dtypes ``.array`` will be a
        :class:`arrays.NumpyExtensionArray` wrapping the actual ndarray
        stored within. If you absolutely need a NumPy array (possibly with
        copying / coercing data), then use :meth:`Series.to_numpy` instead.

        Examples
        --------
        For regular NumPy types like int, and float, a PandasArray
        is returned.

        >>> pd.Series([1, 2, 3]).array
        <PandasArray>
        [1, 2, 3]
        Length: 3, dtype: int64

        For extension types, like Categorical, the actual ExtensionArray
        is returned

        >>> ser = pd.Series(pd.Categorical(['a', 'b', 'a']))
        >>> ser.array
        ['a', 'b', 'a']
        Categories (2, object): ['a', 'b']
        """
        raise AbstractMethodError(self)
Exemplo n.º 3
0
 def _try_convert_dates(self):
     raise AbstractMethodError(self)
Exemplo n.º 4
0
 def aggregate(self, func, *args, **kwargs):
     raise AbstractMethodError(self)
Exemplo n.º 5
0
 def _values(self) -> ExtensionArray | np.ndarray:
     # must be defined here as a property for mypy
     raise AbstractMethodError(self)
Exemplo n.º 6
0
 def _update_inplace(self, result, **kwargs):
     raise AbstractMethodError(self)
Exemplo n.º 7
0
 def _formatter_func(self):
     raise AbstractMethodError(self)
Exemplo n.º 8
0
 def write(self, df, path, compression, **kwargs):
     raise AbstractMethodError(self)
Exemplo n.º 9
0
 def read(self, path, columns=None, **kwargs):
     raise AbstractMethodError(self)
Exemplo n.º 10
0
 def items(self) -> Index:
     raise AbstractMethodError(self)
Exemplo n.º 11
0
 def _equal_values(self: T, other: T) -> bool:
     """
     To be implemented by the subclasses. Only check the column values
     assuming shape and indexes have already been checked.
     """
     raise AbstractMethodError(self)
Exemplo n.º 12
0
 def _update_inplace(self, result, verify_is_copy=True, **kwargs):
     raise AbstractMethodError(self)
Exemplo n.º 13
0
 def insert(self, loc: int, item):
     # ExtensionIndex subclasses must override Index.insert
     raise AbstractMethodError(self)
Exemplo n.º 14
0
    def take(self, indices, allow_fill=False, fill_value=None):
        # type: (Sequence[int], bool, Optional[Any]) -> ExtensionArray
        """Take elements from an array.

        Parameters
        ----------
        indices : sequence of integers
            Indices to be taken.
        allow_fill : bool, default False
            How to handle negative values in `indices`.

            * False: negative values in `indices` indicate positional indices
              from the right (the default). This is similar to
              :func:`numpy.take`.

            * True: negative values in `indices` indicate
              missing values. These values are set to `fill_value`. Any other
              other negative values raise a ``ValueError``.

        fill_value : any, optional
            Fill value to use for NA-indices when `allow_fill` is True.
            This may be ``None``, in which case the default NA value for
            the type, ``self.dtype.na_value``, is used.

            For many ExtensionArrays, there will be two representations of
            `fill_value`: a user-facing "boxed" scalar, and a low-level
            physical NA value. `fill_value` should be the user-facing version,
            and the implementation should handle translating that to the
            physical version for processing the take if necessary.

        Returns
        -------
        ExtensionArray

        Raises
        ------
        IndexError
            When the indices are out of bounds for the array.
        ValueError
            When `indices` contains negative values other than ``-1``
            and `allow_fill` is True.

        Notes
        -----
        ExtensionArray.take is called by ``Series.__getitem__``, ``.loc``,
        ``iloc``, when `indices` is a sequence of values. Additionally,
        it's called by :meth:`Series.reindex`, or any other method
        that causes realignment, with a `fill_value`.

        See Also
        --------
        numpy.take
        pandas.api.extensions.take

        Examples
        --------
        Here's an example implementation, which relies on casting the
        extension array to object dtype. This uses the helper method
        :func:`pandas.api.extensions.take`.

        .. code-block:: python

           def take(self, indices, allow_fill=False, fill_value=None):
               from pandas.core.algorithms import take

               # If the ExtensionArray is backed by an ndarray, then
               # just pass that here instead of coercing to object.
               data = self.astype(object)

               if allow_fill and fill_value is None:
                   fill_value = self.dtype.na_value

               # fill value should always be translated from the scalar
               # type for the array, to the physical storage type for
               # the data, before passing to take.

               result = take(data, indices, fill_value=fill_value,
                             allow_fill=allow_fill)
               return self._from_sequence(result, dtype=self.dtype)
        """
        # Implementer note: The `fill_value` parameter should be a user-facing
        # value, an instance of self.dtype.type. When passed `fill_value=None`,
        # the default of `self.dtype.na_value` should be used.
        # This may differ from the physical storage type your ExtensionArray
        # uses. In this case, your implementation is responsible for casting
        # the user-facing type to the storage type, before using
        # pandas.api.extensions.take
        raise AbstractMethodError(self)
 def _attributes(self):
     # Inheriting subclass should implement _attributes as a list of strings
     raise AbstractMethodError(self)
Exemplo n.º 16
0
 def _chop(self, sdata, slice_obj: slice) -> NDFrame:
     raise AbstractMethodError(self)
 def _simple_new(cls, values, **kwargs):
     raise AbstractMethodError(cls)
Exemplo n.º 18
0
 def dtype(self) -> BaseMaskedDtype:
     raise AbstractMethodError(self)
Exemplo n.º 19
0
 def __unicode__(self):
     raise AbstractMethodError(self)
Exemplo n.º 20
0
 def _coerce_to_array(cls,
                      values,
                      *,
                      dtype: DtypeObj,
                      copy: bool = False) -> tuple[np.ndarray, np.ndarray]:
     raise AbstractMethodError(cls)
Exemplo n.º 21
0
 def _construct_result(self, result, name):
     """
     Construct an appropriately-wrapped result from the ArrayLike result
     of an arithmetic-like operation.
     """
     raise AbstractMethodError(self)
Exemplo n.º 22
0
 def _chop(self, sdata, slice_obj):
     raise AbstractMethodError(self)
Exemplo n.º 23
0
 def dtype(self) -> DtypeObj:
     # must be defined here as a property for mypy
     raise AbstractMethodError(self)
Exemplo n.º 24
0
 def apply(self, f):
     raise AbstractMethodError(self)
Exemplo n.º 25
0
 def __len__(self) -> int:
     # We need this defined here for mypy
     raise AbstractMethodError(self)
 def _box_func(self):
     """
     box function to get object from internal representation
     """
     raise AbstractMethodError(self)
Exemplo n.º 27
0
 def _format_axes(self):
     raise AbstractMethodError(self)
 def _add_offset(self, offset):
     raise AbstractMethodError(self)
Exemplo n.º 29
0
 def dtype(self) -> ExtensionDtype:
     """
     An instance of 'ExtensionDtype'.
     """
     raise AbstractMethodError(self)
Exemplo n.º 30
0
 def _parse_no_numpy(self):
     raise AbstractMethodError(self)