abracudabra.conversion.cframe ============================= .. py:module:: abracudabra.conversion.cframe .. autoapi-nested-parse:: Convert to a Pandas/cuDF series or dataframe. Functions --------- .. autoapisummary:: abracudabra.conversion.cframe.to_series abracudabra.conversion.cframe.to_dataframe Module Contents --------------- .. py:function:: to_series(sequence, /, index = None, device = None, *, strict = False, **kwargs) Convert an array or tensor to a Pandas/cuDF series. :param sequence: The array or tensor to convert. :param index: The optional index for the series. :param device: The device to use for the series. If not provided, the array stays on the same device. :param strict: Whether to raise an error if the sequence is not a NumPy/CuPy array or Torch tensor. :param \*\*kwargs: Additional keyword arguments for the series. :returns: The converted series. .. rubric:: Examples Convert a list to a CuPy series >>> series = to_series([10, 20, 30], device="cuda") >>> print(type(series)) Convert a CuPy array to a cuDF series >>> import cupy as cp >>> cupy_array = cp.array([40, 50, 60]) >>> series = to_series(cupy_array) >>> print(type(series)) .. py:function:: to_dataframe(data, /, index = None, device = None, *, strict = False, **kwargs) Convert to a Pandas/cuDF dataframe. :param data: The data to convert. If a mapping, the keys will be used as column names. :param index: The optional index for the dataframe. :param device: The device to use for the dataframe. If not provided, the type is guessed from the data. :param strict: Whether to raise an error if the provided data does not consist of NumPy/CuPy arrays or Torch tensors. :param \*\*kwargs: Additional keyword arguments for the dataframe. :returns: The converted dataframe. .. rubric:: Examples Build a dataframe from mixed data types >>> import cupy as cp >>> import numpy as np >>> import torch >>> numpy_array = np.full((5,), 1, dtype=np.float32) >>> cupy_array = cp.full((5,), 2, dtype=cp.int8) >>> torch_tensor = torch.full((5,), 3, dtype=torch.float32, device="cuda:0") >>> dataframe = to_dataframe( ... {"numpy": numpy_array, "cupy": cupy_array, "torch": torch_tensor}, ... device="cuda:0", ... ) >>> print(dataframe) numpy cupy torch 0 1.0 2 3.0 1 1.0 2 3.0 2 1.0 2 3.0 3 1.0 2 3.0 4 1.0 2 3.0 >>> print(type(dataframe))