maxframe.dataframe.dtype#

maxframe.dataframe.dtype(type)[source]#

Recommend dtype for MaxFrame DataFrame operations.

Converts various type representations into MaxFrame-compatible dtypes. Returns pd.ArrowDtype for most types and ExternalBlobDtype for blob types.

Parameters:

type (str, np.dtype, pd.ExtensionDtype, odps.types.DataType, pa.DataType, or Python type class) –

The type to convert to MaxFrame-compatible dtype. Supported input types: - str: Type string like ‘int64’, ‘string’, ‘blob’, ‘list<item: int64>’, etc. - np.dtype: NumPy dtype objects - pd.ExtensionDtype: Pandas extension dtypes - odps.types.DataType: ODPS data types (requires odps package) - pa.DataType: PyArrow data types - Python type classes: int, float, bool, str, bytes

(int -> int64, float -> float64, bool -> bool, str -> StringDtype(pyarrow), bytes -> binary)

Returns:

Recommended dtype for use in MaxFrame operations. Returns ExternalBlobDtype for blob types, ArrowDtype for all others.

Return type:

ArrowDtype or ExternalBlobDtype

Raises:

TypeError – If the input type is not supported or cannot be converted.

Examples

>>> import maxframe.dataframe as md
>>> md.dtype("int64")
ArrowDtype(int64[pyarrow])
>>> md.dtype("blob")
ExternalBlobDtype()
>>> import numpy as np
>>> md.dtype(np.dtype('float32'))
ArrowDtype(float[pyarrow])
>>> from odps import types as odps_types
>>> md.dtype(odps_types.string)
ArrowDtype(string[pyarrow])
>>> md.dtype(int)
ArrowDtype(int64[pyarrow])
>>> md.dtype(float)
ArrowDtype(double[pyarrow])
>>> md.dtype(str)
StringDtype(pyarrow)
>>> md.dtype(bytes)
ArrowDtype(binary[pyarrow])