(col: pd.Series)
return col
Guess column types. Logic is same than in guess_data_type from io_utils
    module. This function only change the dtype of the column such that later
    correct Orange.data.variable is used.
    Logic:
    - if can converted to date-time (ISO) -> TimeVariable
    - if numeric (only numbers)
        - only values {0, 1} or {1, 2} -> DiscreteVariable
        - else -> ContinuousVariable
    - if not numbers:
        - num_unique_values < len(data) ** 0.7 and < 100 -> DiscreteVariable
        - else -> StringVariable

    Parameters
    ----------
    col
        Data column

    Returns
    -------
    Data column with correct dtype
Guess column types. Logic is same than in guess_data_type from io_utils
    module. This function only change the dtype of the column such that later
    correct Orange.data.variable is used.
    Logic:
    - if can converted to date-time (ISO) -> TimeVariable
    - if numeric (only numbers)
        - only values {0, 1} or {1, 2} -> DiscreteVariable
        - else -> ContinuousVariable
    - if not numbers:
        - num_unique_values < len(data) ** 0.7 and < 100 -> DiscreteVariable
        - else -> StringVariable
Guess column types . Logic is same than in guess_data_type from io_utils module . This function only change the dtype of the column such that later correct Orange . data . variable is used . Logic : - if can converted to date - time ( ISO ) - > TimeVariable - if numeric ( only numbers ) - only values { 0 1 } or { 1 2 } - > DiscreteVariable - else - > ContinuousVariable - if not numbers : - num_unique_values < len ( data ) ** 0 . 7 and < 100 - > DiscreteVariable - else - > StringVariable
def guess_data_type(col: pd.Series) -> pd.Series:
    """
    Guess column types. Logic is same than in guess_data_type from io_utils
    module. This function only change the dtype of the column such that later
    correct Orange.data.variable is used.
    Logic:
    - if can converted to date-time (ISO) -> TimeVariable
    - if numeric (only numbers)
        - only values {0, 1} or {1, 2} -> DiscreteVariable
        - else -> ContinuousVariable
    - if not numbers:
        - num_unique_values < len(data) ** 0.7 and < 100 -> DiscreteVariable
        - else -> StringVariable

    Parameters
    ----------
    col
        Data column

    Returns
    -------
    Data column with correct dtype
    """
    def parse_dates(s):
        """
        This is an extremely fast approach to datetime parsing.
        For large data, the same dates are often repeated. Rather than
        re-parse these, we store all unique dates, parse them, and
        use a lookup to convert all dates.
        """
        try:
            dates = {date: pd.to_datetime(date) for date in s.unique()}
        except ValueError:
            return None
        return s.map(dates)

    if pdtypes.is_numeric_dtype(col):
        unique_values = col.unique()
        if len(unique_values) <= 2 and (
                len(np.setdiff1d(unique_values, [0, 1])) == 0
                or len(np.setdiff1d(unique_values, [1, 2])) == 0):
            return col.astype("category")
    else:  # object
        # try parse as date - if None not a date
        parsed_col = parse_dates(col)
        if parsed_col is not None:
            return parsed_col
        unique_values = col.unique()
        if len(unique_values) < 100 and len(unique_values) < len(col)**0.7:
            return col.astype("category")
    return col
def guess_data_type ( col : pd . Series ) -> pd . Series : def parse_dates ( s ) : """
        This is an extremely fast approach to datetime parsing.
        For large data, the same dates are often repeated. Rather than
        re-parse these, we store all unique dates, parse them, and
        use a lookup to convert all dates.
        """ try : dates = { date : pd . to_datetime ( date ) for date in s . unique ( ) } except ValueError : return None return s . map ( dates ) if pdtypes . is_numeric_dtype ( col ) : unique_values = col . unique ( ) if len ( unique_values ) <= 2 and ( len ( np . setdiff1d ( unique_values , [ 0 , 1 ] ) ) == 0 or len ( np . setdiff1d ( unique_values , [ 1 , 2 ] ) ) == 0 ) : return col . astype ( "category" ) else : # object # try parse as date - if None not a date parsed_col = parse_dates ( col ) if parsed_col is not None : return parsed_col unique_values = col . unique ( ) if len ( unique_values ) < 100 and len ( unique_values ) < len ( col ) ** 0.7 : return col . astype ( "category" ) return col