def test_to_object_array_tuples(self): r = (5, 6) values = [r] lib.to_object_array_tuples(values) # make sure record array works record = namedtuple("record", "x y") r = record(5, 6) values = [r] lib.to_object_array_tuples(values)
def test_to_object_array_tuples(self): r = (5, 6) values = [r] result = lib.to_object_array_tuples(values) try: # make sure record array works from collections import namedtuple record = namedtuple('record', 'x y') r = record(5, 6) values = [r] result = lib.to_object_array_tuples(values) # noqa except ImportError: pass
def _list_to_arrays(data, columns, coerce_float=False, dtype=None): if len(data) > 0 and isinstance(data[0], tuple): content = list(lib.to_object_array_tuples(data).T) else: # list of lists content = list(lib.to_object_array(data).T) return _convert_object_array(content, columns, dtype=dtype, coerce_float=coerce_float)
def _list_to_arrays(data: list[tuple | list]) -> np.ndarray: # Returned np.ndarray has ndim = 2 # Note: we already check len(data) > 0 before getting hre if isinstance(data[0], tuple): content = lib.to_object_array_tuples(data) else: # list of lists content = lib.to_object_array(data) return content
def _list_to_arrays( data: List[Scalar], columns: Union[Index, List], ) -> Tuple[List[Scalar], Union[Index, List[Axis]]]: # Note: we already check len(data) > 0 before getting hre if isinstance(data[0], tuple): content = lib.to_object_array_tuples(data) else: # list of lists content = lib.to_object_array(data) return content, columns
def _list_to_arrays(data, columns, coerce_float=False, dtype=None): if len(data) > 0 and isinstance(data[0], tuple): content = list(lib.to_object_array_tuples(data).T) else: # list of lists content = list(lib.to_object_array(data).T) # gh-26429 do not raise user-facing AssertionError try: result = _convert_object_array( content, columns, dtype=dtype, coerce_float=coerce_float ) except AssertionError as e: raise ValueError(e) from e return result
def _list_to_arrays( data: List[Scalar], columns: Union[Index, List], coerce_float: bool = False, dtype: Optional[DtypeObj] = None, ) -> Tuple[List[Scalar], Union[Index, List[Axis]]]: if len(data) > 0 and isinstance(data[0], tuple): content = list(lib.to_object_array_tuples(data).T) else: # list of lists content = list(lib.to_object_array(data).T) # gh-26429 do not raise user-facing AssertionError try: columns = _validate_or_indexify_columns(content, columns) result = _convert_object_array(content, dtype=dtype, coerce_float=coerce_float) except AssertionError as e: raise ValueError(e) from e return result, columns