data_algebra/util.py
def guess_column_types(d, *, columns: Optional[Iterable[str]] = None) -> Dict[str, type]:
    """
    Guess column types as type of first non-missing value.
    Will not return series types, as some pandas data frames with non-trivial indexing report this type.

    :param d: pandas.DataFrame
    :param columns: list of columns to check, if None all columns are checked
    :return: map of column names to guessed types, empty dict if any column guess fails
    """
    if (d.shape[0] <= 0) or (d.shape[1] <= 0):
        return dict()
    if columns is None:
        columns = d.columns.copy()
    assert len(set(columns) - set(d.columns)) == 0
    if len(columns) <= 0:
        return dict()
    res = dict()
    for c in columns:
        gt = guess_carried_scalar_type(d[c])
        if (gt is None) or (not isinstance(gt, type)) or gt == data_algebra.default_data_model.pd.core.series.Series:
            # pandas.concat() poisons types with Series, don't allow that
            return dict()
        res[c] = gt
    return res

    Guess column types as type of first non-missing value.
    Will not return series types, as some pandas data frames with non-trivial indexing report this type.

    :param d: pandas.DataFrame
    :param columns: list of columns to check, if None all columns are checked
    :return: map of column names to guessed types, empty dict if any column guess fails
    
Guess column types as type of first non-missing value.
Will not return series types, as some pandas data frames with non-trivial indexing report this type.
Guess column types as type of first non - missing value . Will not return series types as some pandas data frames with non - trivial indexing report this type .
def guess_column_types(d, *, columns: Optional[Iterable[str]] = None) -> Dict[str, type]:
    if (d.shape[0] <= 0) or (d.shape[1] <= 0):
        return dict()
    if columns is None:
        columns = d.columns.copy()
    assert len(set(columns) - set(d.columns)) == 0
    if len(columns) <= 0:
        return dict()
    res = dict()
    for c in columns:
        gt = guess_carried_scalar_type(d[c])
        if (gt is None) or (not isinstance(gt, type)) or gt == data_algebra.default_data_model.pd.core.series.Series:
            return dict()
        res[c] = gt
    return res
def guess_column_types ( d , * , columns : Optional [ Iterable [ str ] ] = None ) -> Dict [ str , type ] : if ( d . shape [ 0 ] <= 0 ) or ( d . shape [ 1 ] <= 0 ) : return dict ( ) if columns is None : columns = d . columns . copy ( ) assert len ( set ( columns ) - set ( d . columns ) ) == 0 if len ( columns ) <= 0 : return dict ( ) res = dict ( ) for c in columns : gt = guess_carried_scalar_type ( d [ c ] ) if ( gt is None ) or ( not isinstance ( gt , type ) ) or gt == data_algebra . default_data_model . pd . core . series . Series : return dict ( ) res [ c ] = gt return res
Guess column types as type of first non-missing value.
Guess column types as type of first non - missing value .
"""
    Guess column types as type of first non-missing value.
    Will not return series types, as some pandas data frames with non-trivial indexing report this type.

    :param d: pandas.DataFrame
    :param columns: list of columns to check, if None all columns are checked
    :return: map of column names to guessed types, empty dict if any column guess fails
    """ # pandas.concat() poisons types with Series, don't allow that
map of column names to guessed types, empty dict if any column guess fails
map of column names to guessed types empty dict if any column guess fails
d
None
columns
Optional[Iterable[str]]
list of columns to check, if None all columns are checked
list of columns to check if None all columns are checked