H5array#

class h5pandas.HDF5ExtensionArray(dataset: Dataset, column_index: int = 0, dtype=None)[source]#

HDF5ExtensionArray.

argmax(skipna=True)[source]#

Return for indice of max value.

argmin(skipna=True)[source]#

Return for indice of min value.

astype(dtype, copy: bool = True) ExtensionArray | ndarray[source]#

Cast to a NumPy array or ExtensionArray with ‘dtype’.

Parameters#

dtype: str or dtype

Typecode or data-type to which the array is cast.

copy: bool, default True

Whether to copy the data, even if not necessary. If False, a copy is made only if the old dtype does not match the new dtype.

Returns#

np.ndarray or pandas.api.extensions.ExtensionArray

An ExtensionArray if dtype is Extensionnp.dtype, Otherwise a NumPy ndarray with ‘dtype’ for its dtype.

copy()[source]#

Return a copy of the array.

Returns#

ExtensionArray

dropna()[source]#

Remove missing values.

property dtype: HDF5Dtype#

An instance of ‘np.dtype’.

interpolate(*, method: Literal['linear', 'time', 'index', 'values', 'nearest', 'zero', 'slinear', 'quadratic', 'cubic', 'barycentric', 'polynomial', 'krogh', 'piecewise_polynomial', 'spline', 'pchip', 'akima', 'cubicspline', 'from_derivatives'], axis: int, index: Index, limit, limit_direction, limit_area, copy: bool, **kwargs)[source]#

See NDFrame.interpolate.__doc__.

isna() ndarray[source]#

A 1-D array indicating if each value is missing.

Returns#

numpy.ndarray or pandas.api.extensions.ExtensionArray

In most cases, this should return a NumPy ndarray. For exceptional cases like SparseArray, where returning an ndarray would be expensive, an ExtensionArray may be returned.

Notes#

If returning an ExtensionArray, then

  • na_values._is_boolean should be True

  • na_values should implement: func: ExtensionArray._reduce

  • na_values.any and na_values.all should be implemented

property nbytes: int#

The number of bytes needed to store this object in memory.

property ndim: int#

Extension Arrays are only allowed to be 1-dimensional.

property shape#

Return a tuple of the array dimensions.

property size: int#

The number of elements in the array.

take(indices, allow_fill=False, fill_value=None)[source]#

Take elements from an array.

Parameters#

indicessequence of int or one-dimensional np.ndarray of int

Indices to be taken.

allow_fillbool, 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 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_valueany, 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.

See Also#

numpy.take : Take elements from an array along an axis. api.extensions.take : Take elements from an array.

Notes#

ExtensionArray.take is called by Series.__getitem__, .loc, iloc, when indices is a sequence of values. Additionally, it’s called by Series.reindex(), or any other method that causes realignment, with a fill_value.

Examples#

Here’s an example implementation, which relies on casting the extension array to object dtype. This uses the helper method pandas.api.extensions.take().

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)
to_numpy(dtype: dtype | None = None, copy: bool = False, na_value: object = <no_default>) ndarray[source]#

Convert to a NumPy ndarray.

This is similar to: meth: numpy.asarray, but may provide additional control over how the conversion is done.

Parameters#

dtype: str or numpy.dtype, optional

The dtype to pass to: meth: numpy.asarray.

copy: bool, default False

Whether to ensure that the returned value is a not a view on another array. Note that copy = False does not *ensure * that to_numpy() is no-copy. Rather, copy = True ensure that a copy is made, even if not strictly necessary.

na_value: Any, optional

The value to use for missing values. The default value depends on dtype and the type of the array.

Returns#

numpy.ndarray

unique() ndarray[source]#

Compute the ExtensionArray of unique values.

Returns#

pandas.api.extensions.ExtensionArray

Examples#

>>> arr = pd.array([1, 2, 3, 1, 2, 3])
>>> arr.unique()
<IntegerArray>
[1, 2, 3]
Length: 3, dtype: Int64
value_counts(dropna: bool = True) Series[source]#

Return a Series containing counts of unique values.

Parameters#

dropnabool, optional

Don’t include counts of NaN. The default is True.

Returns#

Series

value_counts.

view(dtype: ExtensionDtype | str | dtype | Type[str | complex | bool | object] | None = None) ExtensionArray | ndarray[source]#

Return a view on the array.

Parameters#

dtypestr, np.dtype, or ExtensionDtype, optional

Default None.

Returns#

ExtensionArray or np.ndarray

A view on the ExtensionArray’s data.

Examples#

This gives view on the underlying data of an ExtensionArray and is not a copy. Modifications on either the view or the original ExtensionArray will be reflectd on the underlying data:

>>> arr = pd.array([1, 2, 3])
>>> arr2 = arr.view()
>>> arr[0] = 2
>>> arr2
<IntegerArray>
[2, 2, 3]
Length: 3, dtype: Int64