data_algebra/util.py
def guess_carried_scalar_type(col) -> type:
    """
    Guess the type of a column or scalar.

    :param col: column or scalar to inspect
    :return: type of first non-None entry, if any , else type(None)
    """
    # check for scalars first
    ct = map_type_to_canonical(type(col))
    if ct in {str, int, float, bool, type(None), numpy.int64, numpy.float64,
              datetime.datetime, datetime.date, datetime.timedelta}:
        return ct
    # look at a list or Series
    if isinstance(col, data_algebra.default_data_model.pd.core.series.Series):
        col = col.values
    if len(col) < 1:
        return type(None)
    good_idx = numpy.where(numpy.logical_not(data_algebra.default_data_model.pd.isna(col)))[0]
    test_idx = 0
    if len(good_idx) > 0:
        test_idx = good_idx[0]
    return map_type_to_canonical(type(col[test_idx]))

    Guess the type of a column or scalar.

    :param col: column or scalar to inspect
    :return: type of first non-None entry, if any , else type(None)
    
Guess the type of a column or scalar.
Guess the type of a column or scalar .
def guess_carried_scalar_type(col) -> type:
    ct = map_type_to_canonical(type(col))
    if ct in {str, int, float, bool, type(None), numpy.int64, numpy.float64,
              datetime.datetime, datetime.date, datetime.timedelta}:
        return ct
    if isinstance(col, data_algebra.default_data_model.pd.core.series.Series):
        col = col.values
    if len(col) < 1:
        return type(None)
    good_idx = numpy.where(numpy.logical_not(data_algebra.default_data_model.pd.isna(col)))[0]
    test_idx = 0
    if len(good_idx) > 0:
        test_idx = good_idx[0]
    return map_type_to_canonical(type(col[test_idx]))
def guess_carried_scalar_type ( col ) -> type : ct = map_type_to_canonical ( type ( col ) ) if ct in { str , int , float , bool , type ( None ) , numpy . int64 , numpy . float64 , datetime . datetime , datetime . date , datetime . timedelta } : return ct if isinstance ( col , data_algebra . default_data_model . pd . core . series . Series ) : col = col . values if len ( col ) < 1 : return type ( None ) good_idx = numpy . where ( numpy . logical_not ( data_algebra . default_data_model . pd . isna ( col ) ) ) [ 0 ] test_idx = 0 if len ( good_idx ) > 0 : test_idx = good_idx [ 0 ] return map_type_to_canonical ( type ( col [ test_idx ] ) )
Guess the type of a column or scalar.
Guess the type of a column or scalar .
"""
    Guess the type of a column or scalar.

    :param col: column or scalar to inspect
    :return: type of first non-None entry, if any , else type(None)
    """ # check for scalars first # look at a list or Series
type of first non-None entry, if any , else type(None)
type of first non - None entry if any else type ( None )
col
column or scalar to inspect
column or scalar to inspect