abracudabra.conversion.cframe#

Convert to a pandas/cudf series or dataframe.

Functions#

_guess_dataframe_device(→ abracudabra.device.base.Device)

Guess the device of a dataframe.

to_series(→ abracudabra.annotations.Series)

Convert an array or tensor to a pandas/cudf series.

to_dataframe(→ abracudabra.annotations.DataFrame)

Convert to a pandas/cudf dataframe.

Module Contents#

abracudabra.conversion.cframe._guess_dataframe_device(sequences: collections.abc.Iterable[torch.Tensor | abracudabra.annotations.Array], /, device: str | abracudabra.device.base.Device | None = None) abracudabra.device.base.Device[source]#

Guess the device of a dataframe.

abracudabra.conversion.cframe.to_series(sequence: object, /, index: abracudabra.annotations.Array | torch.Tensor | None = None, device: str | abracudabra.device.base.Device | None = None, *, strict: bool = False, **kwargs: Any) abracudabra.annotations.Series[source]#

Convert an array or tensor to a pandas/cudf series.

Parameters:
  • sequence – The array or tensor to convert.

  • index – The optional index for the series.

  • device – The device to use for the series.

  • strict – Whether to raise an error for unknown data types.

  • kwargs – Additional keyword arguments for the series.

Returns:

The converted series.

abracudabra.conversion.cframe.to_dataframe(data: collections.abc.Mapping[str, abracudabra.annotations.Array | torch.Tensor] | torch.Tensor | abracudabra.annotations.Array, /, index: abracudabra.annotations.Array | torch.Tensor | None = None, device: str | abracudabra.device.base.Device | None = None, *, strict: bool = False, **kwargs: Any) abracudabra.annotations.DataFrame[source]#

Convert to a pandas/cudf dataframe.

Parameters:
  • data – The data to convert. If a mapping, the keys will be used as column names.

  • index – The optional index for the dataframe.

  • device – The device to use for the dataframe.

  • strict – Whether to raise an error for unknown data types.

  • kwargs – Additional keyword arguments for the dataframe.

Returns:

The converted dataframe.