Return True if value is a type we expect in a dataframe
334457
def is_known_scalar(value):
    
    def _is_datetime_or_timedelta(value):
        # Using pandas.Series helps catch python, numpy and pandas
        # versions of these types
        return pd.Series(value).dtype.kind in ('M', 'm')

    return not np.iterable(value) and (isinstance(value, numbers.Number) or
                                       _is_datetime_or_timedelta(value))
80466
function isJSValueCompatibleWithColumnType(value, columnType) {
    
    // Allow NULL values to be stored in columns of any type
    if (_.isNull(value)) {
        return true;
    }
    
    switch (columnType) {
        case ColumnType.Object:
            return _.isObject(value);
        case ColumnType.Array:
            return _.isArray(value);
        case ColumnType.String:
        case ColumnType.Text:
            return true; // Allow any value to be stored in a string column
        case ColumnType.Boolean:
        case ColumnType.Bool:
        case ColumnType.Integer:
        case ColumnType.Int:
            return _.isBool(value) || _.isInteger(value);
        case ColumnType.Date:
            return _.isDate(value);
        case ColumnType.Real:
        case ColumnType.Float:
            return _.isNumber(value);
        default:
            return false;
    }
}
1148304
def set_features_types_from_dataframe(self, data_frame):
        
        if self.__feature_types_set:
            return
        self.__feature_types_set = True

        dtypes = data_frame.dtypes
        for feature in self.__iter__():
            name = feature.get_name()
            type_name = data_type_to_type_name(dtypes[name])
            feature.set_type_name(type_name)
383685
def _isstring(dtype):
    
    return dtype.type == numpy.unicode_ or dtype.type == numpy.string_
1203032
def isdatetime(value):
    
    if isinstance(value, np.ndarray):
        return (value.dtype.kind == "M" or
                (value.dtype.kind == "O" and len(value) and
                 isinstance(value[0], datetime_types)))
    else:
        return isinstance(value, datetime_types)
474293
def is_array(self, data_type):
    '''
    '''

    # Split off any brackets
    data_type = data_type.split('[')[0].strip()

    return data_type.lower() in self.array_types
1086451
def _is_type(self, instance, type):
        
        if type not in self._types:
            raise UnknownType(type)
        type = self._types[type]

        # bool inherits from int, so ensure bools aren't reported as integers
        if isinstance(instance, bool):
            type = _flatten(type)
            if int in type and bool not in type:
                return False
        return isinstance(instance, type)
160445
def is_categorical_astype(self, dtype):
        
        if dtype is Categorical or dtype is CategoricalDtype:
            # this is a pd.Categorical, but is not
            # a valid type for astypeing
            raise TypeError("invalid type {0} for astype".format(dtype))

        elif is_categorical_dtype(dtype):
            return True

        return False
107189
def _is_not_considered_falsey(value, ignore_types=()):
    '''
    
    '''
    return isinstance(value, bool) or type(value) in ignore_types or value
810640
function isType(type, val) {
  if (Struct.typeChecker[type]) {
    return Struct.typeChecker[type](val);
  }
  return false;
}
125420
def _check_type(self, check_type, properties):
        """"""
        if 'PrimitiveType' in properties:
            return properties['PrimitiveType'] == check_type
        if properties['Type'] == 'List':
            if 'ItemType' in properties:
                return properties['ItemType'] == check_type
            else:
                return properties['PrimitiveItemType'] == check_type
        return False
666986
def is_primitive(self):
        """"""
        if is_py2:
            return isinstance(
                self.val, 
                (
                    types.NoneType,
                    types.BooleanType,
                    types.IntType,
                    types.LongType,
                    types.FloatType
                )
            )

        else:
            return isinstance(
                self.val,
                (
                    type(None),
                    bool,
                    int,
                    float
                )
            )
757683
def restore_type(self, dtype, sample=None):
        

        # Pandas types
        if pdc.is_bool_dtype(dtype):
            return 'boolean'
        elif pdc.is_datetime64_any_dtype(dtype):
            return 'datetime'
        elif pdc.is_integer_dtype(dtype):
            return 'integer'
        elif pdc.is_numeric_dtype(dtype):
            return 'number'

        # Python types
        if sample is not None:
            if isinstance(sample, (list, tuple)):
                return 'array'
            elif isinstance(sample, datetime.date):
                return 'date'
            elif isinstance(sample, isodate.Duration):
                return 'duration'
            elif isinstance(sample, dict):
                return 'object'
            elif isinstance(sample, six.string_types):
                return 'string'
            elif isinstance(sample, datetime.time):
                return 'time'

        return 'string'
696214
def retype(value, index_column=None):
        
        if index_column is None:
            index_column = 'date'

        if isinstance(value, pd.DataFrame):
            # use all lower case for column name
            value.columns = map(lambda c: c.lower(), value.columns)

            if index_column in value.columns:
                value.set_index(index_column, inplace=True)
            value = StockDataFrame(value)
        return value
437991
def get_type_string(item):
    """"""
    if isinstance(item, DataFrame):
        return "DataFrame"
    if isinstance(item, Index):
        return type(item).__name__
    if isinstance(item, Series):
        return "Series"
    found = re.findall(r"<(?:type|class) '(\S*)'>",
                       to_text_string(type(item)))
    if found:
        return found[0]
1360092
def types_(self, col: str) -> pd.DataFrame:
        
        cols = self.df.columns.values
        all_types = {}
        for col in cols:
            local_types = []
            for i, val in self.df[col].iteritems():
                #print(i, val, type(val))
                t = type(val).__name__
                if t not in local_types:
                    local_types.append(t)
            all_types[col] = (local_types, i)
        df = pd.DataFrame(all_types, index=["type", "num"])
        return df
971695
def should_display_warnings_for(to_type):
    
    if not hasattr(to_type, '__module__'):
        return True
    elif to_type.__module__ in {'builtins'} or to_type.__module__.startswith('parsyfiles') \
            or to_type.__name__ in {'DataFrame'}:
        return False
    elif issubclass(to_type, int) or issubclass(to_type, str) \
            or issubclass(to_type, float) or issubclass(to_type, bool):
        return False
    else:
        return True