Ejemplo n.º 1
0
def cast_series(series: pd.Series, typeset: VisionsTypeset) -> pd.Series:
    """Casts the series

    Args:
        series: the Series to infer the type of
        typeset: the Typeset that provides the type context

    Returns:
        The converted series
    """
    return typeset.cast_series(series)
Ejemplo n.º 2
0
def detect_type(data: Sequence,
                typeset: VisionsTypeset) -> Union[Dict[str, T], T]:
    """Detect the type in the base graph

    Args:
        data: the DataFrame to detect types on
        typeset: the Typeset that provides the type context

    Returns:
        A dictionary with a mapping from column name to type
    """
    return typeset.detect_type(data)
Ejemplo n.º 3
0
def infer_type(data: Sequence,
               typeset: VisionsTypeset) -> Union[Dict[str, T], T]:
    """Infer the current types of each column in the DataFrame given the typeset.

    Args:
        data: the DataFrame to infer types on
        typeset: the Typeset that provides the type context

    Returns:
        A dictionary with a mapping from column name to type
    """
    return typeset.infer_type(data)
Ejemplo n.º 4
0
def cast_to_inferred(data: Sequence, typeset: VisionsTypeset) -> Sequence:
    """Casts a DataFrame into a typeset by first performing column wise type inference against
    a provided typeset

    Args:
        data: the DataFrame to cast
        typeset: the Typeset in which we cast

    Returns:
        A tuple of the casted DataFrame and the types to which the columns were cast
    """
    return typeset.cast_to_inferred(data)
Ejemplo n.º 5
0
def infer_series_type(series: pd.Series,
                      typeset: VisionsTypeset) -> Type[VisionsBaseType]:
    """Infer the current type of the series given the typeset

    Args:
        series: the Series to infer the type of
        typeset: the Typeset that provides the type context

    Returns:
        The inferred type of the series
    """
    return typeset.infer_series_type(series)
Ejemplo n.º 6
0
def detect_series_type(series: pd.Series,
                       typeset: VisionsTypeset) -> Type[VisionsBaseType]:
    """Detect the type in the base graph

    Args:
        series: the Series to detect the type of
        typeset: the Typeset that provides the type context

    Returns:
        The detected type
    """
    return typeset.detect_series_type(series)
Ejemplo n.º 7
0
def cast_to_detected(data: Union[pd.Series, pd.DataFrame],
                     typeset: VisionsTypeset) -> pd.DataFrame:
    """Casts a DataFrame into a typeset by first performing column wise type inference against
    a provided typeset

    Args:
        df: the DataFrame to cast
        typeset: the Typeset in which we cast

    Returns:
        A tuple of the casted DataFrame and the types to which the columns were cast
    """
    return typeset.cast_to_detected(data)
Ejemplo n.º 8
0
def detect_type(
    data: Union[pd.Series, pd.DataFrame], typeset: VisionsTypeset
) -> Union[Dict[str, Type[VisionsBaseType]], Type[VisionsBaseType]]:
    """Detect the type in the base graph

    Args:
        df: the DataFrame to detect types on
        typeset: the Typeset that provides the type context

    Returns:
        A dictionary with a mapping from column name to type
    """
    return typeset.detect_type(data)
Ejemplo n.º 9
0
def infer_type(
    data: Union[pd.Series, pd.DataFrame], typeset: VisionsTypeset
) -> Union[Dict[str, Type[VisionsBaseType]], Type[VisionsBaseType]]:
    """Infer the current types of each column in the DataFrame given the typeset.

    Args:
        df: the DataFrame to infer types on
        typeset: the Typeset that provides the type context

    Returns:
        A dictionary with a mapping from column name to type
    """
    return typeset.infer_type(data)
Ejemplo n.º 10
0
def cast_and_infer_series(
        series: pd.Series,
        typeset: VisionsTypeset) -> Tuple[Type[VisionsBaseType], pd.Series]:
    """Cast the series and perform type inference

    Args:
        series: the Series to infer the type of
        typeset: the Typeset that provides the type context

    Returns:
        The inferred type and the converted series
    """
    return typeset.cast_and_infer_series(series)
Ejemplo n.º 11
0
def cast_and_infer_frame(df: pd.DataFrame,
                         typeset: VisionsTypeset) -> Tuple[pd.DataFrame, dict]:
    """Casts a DataFrame into a typeset by first performing column wise type inference against
    a provided typeset

    Args:
        df: the DataFrame to cast
        typeset: the Typeset in which we cast

    Returns:
        A tuple of the casted DataFrame and the types to which the columns were cast
    """
    return typeset.cast_and_infer_frame(df)