Exemplo n.º 1
0
    def _cast(self, val: Any, dtype: pa.DataType) -> Any:
        """Fix columns with mixed/serialized dtypes"""

        if not val:
            return None

        if is_string(dtype):
            casted = str(val)
        elif is_floating(dtype):
            casted = self._cast_float(val, dtype)
        elif is_temporal(dtype):
            casted = self._cast_temporal(val, dtype)
        else:
            casted = val
        return casted
Exemplo n.º 2
0
def test_is_floating():
    for t in [pa.float16(), pa.float32(), pa.float64()]:
        assert types.is_floating(t)

    assert not types.is_floating(pa.int32())
Exemplo n.º 3
0
def is_float(arrow_type: DataType, /) -> bool:
    """Check if data type is float."""
    return is_floating(arrow_type) or is_decimal(arrow_type)
Exemplo n.º 4
0
def test_is_floating():
    for t in [pa.float16(), pa.float32(), pa.float64()]:
        assert types.is_floating(t)

    assert not types.is_floating(pa.int32())
Exemplo n.º 5
0
def is_float(arrow_type):
    return is_floating(arrow_type) or is_decimal(arrow_type)