Parse a single column. Set properties like .isDatetime and .isNumeric.
550669
function (column, col) {
		var rawColumns = this.rawColumns,
			columns = this.columns, 
			row = column.length,
			val,
			floatVal,
			trimVal,
			trimInsideVal,
			firstRowAsNames = this.firstRowAsNames,
			isXColumn = inArray(col, this.valueCount.xColumns) !== -1,
			dateVal,
			backup = [],
			diff,
			chartOptions = this.chartOptions,
			descending,
			columnTypes = this.options.columnTypes || [],
			columnType = columnTypes[col],
			forceCategory = isXColumn && ((chartOptions && chartOptions.xAxis && splat(chartOptions.xAxis)[0].type === 'category') || columnType === 'string');
		
		if (!rawColumns[col]) {
			rawColumns[col] = [];
		}
		while (row--) {
			val = backup[row] || column[row];
			
			trimVal = this.trim(val);
			trimInsideVal = this.trim(val, true);
			floatVal = parseFloat(trimInsideVal);

			// Set it the first time
			if (rawColumns[col][row] === undefined) {
				rawColumns[col][row] = trimVal;
			}
			
			// Disable number or date parsing by setting the X axis type to category
			if (forceCategory || (row === 0 && firstRowAsNames)) {
				column[row] = trimVal;

			} else if (+trimInsideVal === floatVal) { // is numeric
			
				column[row] = floatVal;
				
				// If the number is greater than milliseconds in a year, assume datetime
				if (floatVal > 365 * 24 * 3600 * 1000 && columnType !== 'float') {
					column.isDatetime = true;
				} else {
					column.isNumeric = true;
				}

				if (column[row + 1] !== undefined) {
					descending = floatVal > column[row + 1];
				}
			
			// String, continue to determine if it is a date string or really a string
			} else {
				dateVal = this.parseDate(val);
				// Only allow parsing of dates if this column is an x-column
				if (isXColumn && typeof dateVal === 'number' && !isNaN(dateVal) && columnType !== 'float') { // is date
					backup[row] = val; 
					column[row] = dateVal;
					column.isDatetime = true;

					// Check if the dates are uniformly descending or ascending. If they 
					// are not, chances are that they are a different time format, so check
					// for alternative.
					if (column[row + 1] !== undefined) {
						diff = dateVal > column[row + 1];
						if (diff !== descending && descending !== undefined) {
							if (this.alternativeFormat) {
								this.dateFormat = this.alternativeFormat;
								row = column.length;
								this.alternativeFormat = this.dateFormats[this.dateFormat].alternative;
							} else {
								column.unsorted = true;
							}
						}
						descending = diff;
					}
				
				} else { // string
					column[row] = trimVal === '' ? null : trimVal;
					if (row !== 0 && (column.isDatetime || column.isNumeric)) {
						column.mixed = true;
					}
				}
			}
		}

		// If strings are intermixed with numbers or dates in a parsed column, it is an indication
		// that parsing went wrong or the data was not intended to display as numbers or dates and 
		// parsing is too aggressive. Fall back to categories. Demonstrated in the 
		// highcharts/demo/column-drilldown sample.
		if (isXColumn && column.mixed) {
			columns[col] = rawColumns[col];
		}

		// If the 0 column is date or number and descending, reverse all columns. 
		if (isXColumn && descending && this.options.sort) {
			for (col = 0; col < columns.length; col++) {
				columns[col].reverse();
				if (firstRowAsNames) {
					columns[col].unshift(columns[col].pop());
				}
			}
		}
	}
1164339
public ColumnType getType(int column) {
        if (column < 0 || column >= columnMetaData.size())
            throw new IllegalArgumentException(
                            "Invalid column number. " + column + "only " + columnMetaData.size() + "present.");
        return columnMetaData.get(column).getColumnType();
    }
10280
protected function parseColumn($column) {
		if ($column instanceof Column) {
			$type = $column->getType();
			return empty($type) ? $column->getName() : $column->getName() . ':' . $type;
		}
		
		return $column;
	}
1224203
private Column prepareColumn(byte[] value, byte[] name, long timestamp, int ttl)
    {
        Column column = new Column();
        column.setName(name);
        column.setValue(value);
        column.setTimestamp(timestamp);
        if (ttl != 0)
        {
            column.setTtl(ttl);
        }
        return column;
    }
961396
private void parseCreateColumn(TableBuilderKraken factory, String name)
  {
    Token token;

    if ((token = scanToken()) != Token.IDENTIFIER) {
      throw error(L.l("expected column type at {0}", token));
    }

    String type = _lexeme;
    int length = -1;
    int scale = -1;

    if (type.equalsIgnoreCase("double")) {
      if ((token = peekToken()) == Token.IDENTIFIER) {
        scanToken();
        
        if (_lexeme.equalsIgnoreCase("precision")) {
        }
        else
          throw error(L.l("unexpected double type at {0}", _lexeme));
      }
    }

    if ((token = peekToken()) == Token.LPAREN) {
      scanToken();
      
      if ((token = scanToken()) != Token.INTEGER) {
        throw error("expected column width at '{0}'", token);
      }

      length = Integer.parseInt(_lexeme);

      if ((token = scanToken()) == Token.COMMA) {
        if ((token = scanToken()) != Token.INTEGER) {
          throw error("expected column scale at '{0}'", token);
        }

        scale = Integer.parseInt(_lexeme);

        token = scanToken();
      }

      if (token != Token.RPAREN) {
        throw error("expected ')' at '{0}'", token);
      }
    }

    if (type.equalsIgnoreCase("varchar")) {
      /*
      if (length < 0) {
        throw error(L.l("VARCHAR needs a defined length"));
      }
      */

      // factory.addVarchar(name, length);
      factory.addVarchar(name, length);
    }
    else if (type.equalsIgnoreCase("blob")) {
      factory.addBlob(name);
    }
    else if (type.equalsIgnoreCase("string")) {
      factory.addString(name);
    }
    else if (type.equalsIgnoreCase("object")) {
      factory.addObject(name);
    }
    else if (type.equalsIgnoreCase("char")) {
      length = Math.max(length, 1);

      factory.addVarchar(name, length);
    }
    else if (type.equalsIgnoreCase("varbinary")) {
      if (length < 0) {
        throw error("VARBINARY needs a defined length");
      }

      factory.addVarbinary(name, length);
    }
    else if (type.equalsIgnoreCase("binary")
        || type.equalsIgnoreCase("bytes")) {
      if (length < 0)
        throw error(L.l("BINARY needs a defined length"));

      factory.addBytes(name, length);
    }
    /*
    else if (type.equalsIgnoreCase("tinytext")) {
      factory.addTinytext(name);
    }
    */
    else if (type.equalsIgnoreCase("mediumtext")) {
      factory.addVarchar(name, 256);
    }
    else if (type.equalsIgnoreCase("longtext")) {
      factory.addVarchar(name, 512);
    }
    else if (type.equalsIgnoreCase("bit")
             || type.equalsIgnoreCase("bool")) {
      factory.addBool(name);
    }
    else if (type.equalsIgnoreCase("tinyint")
        || type.equalsIgnoreCase("bit")
        || type.equalsIgnoreCase("int8")) {
      factory.addInt8(name);
    }
    else if (type.equalsIgnoreCase("smallint")
             || type.equalsIgnoreCase("int16")) {
      factory.addInt16(name);
    }
    else if (type.equalsIgnoreCase("integer")
             || type.equalsIgnoreCase("int")
             || type.equalsIgnoreCase("mediumint")
             || type.equalsIgnoreCase("int32")) {
      factory.addInt32(name);
    }
    else if (type.equalsIgnoreCase("bigint")
             || type.equalsIgnoreCase("long")
             || type.equalsIgnoreCase("int64")) {
      factory.addInt64(name);
    }
    else if (type.equalsIgnoreCase("double")
            || type.equalsIgnoreCase("float64")
            || type.equalsIgnoreCase("real")) {
      factory.addDouble(name);
    }
    else if (type.equalsIgnoreCase("float")
             || type.equalsIgnoreCase("float32")) {
      factory.addFloat(name);
    }
    else if (type.equalsIgnoreCase("datetime")
             || type.equalsIgnoreCase("timestamp")) {
      factory.addDateTime(name);
    }
    else if (type.equalsIgnoreCase("text")
             || type.equalsIgnoreCase("clob")) {
      factory.addVarchar(name, 255);
    }
    else if (type.equalsIgnoreCase("identity")) {
      factory.addIdentity(name);
    }
    else
      throw error(L.l("Unknown type {0}", type));

    /*
    token = scanToken();
    if (token == IDENTIFIER && _lexeme.equalsIgnoreCase("default")) {
      Expr defaultExpr = parseExpr();

      factory.setDefault(name, defaultExpr);
    }
    else {
      _token = token;
    }
    */

    while (true) {
      token = scanToken();

      // XXX: stuff like NOT NULL

      switch (token) {
      case RPAREN:
      case COMMA:
        _token = token;
        return;

        /*
      case UNIQUE:
        factory.setUnique(name);
        break;
        */

      case PRIMARY:
        token = scanToken();
        if (token != Token.KEY)
          throw error("expected key at {0}", token);

        factory.setPrimaryKey(name);
        break;

        /*
      case CHECK:
        if ((token = scanToken()) != '(')
          throw error(L.l("Expected '(' at '{0}'", tokenName(token)));

        parseExpr();

        if ((token = scanToken()) != ')')
          throw error(L.l("Expected ')' at '{0}'", tokenName(token)));
        break;
        */

        /*
      case IDENTIFIER:
        String id = _lexeme;
        if (id.equalsIgnoreCase("references")) {
          ArrayList<String> foreignKey = new ArrayList<String>();
          foreignKey.add(name);
          parseReferences(foreignKey);
        }
        else if (id.equalsIgnoreCase("default")) {
          Expr expr = parseExpr();
        }
        else if (id.equalsIgnoreCase("auto_increment")) {
          factory.setAutoIncrement(name, 1);
        }
        else if (id.equalsIgnoreCase("unsigned")) {
        }
        else if (id.equalsIgnoreCase("binary")) {
        }
        else
          throw error(L.l("unexpected token '{0}'", tokenName(token)));
        break;
        */

      case NULL:
        break;

      case NOT:
        if ((token = scanToken()) == Token.NULL)
          factory.setNotNull(name);
        else
          throw error("unexpected token '{0}'", token);
        break;

      default:
        throw error("unexpected token '{0}'", token);
      }
    }
  }
1155
function parseSQLVal(type, val) {
	if (val == 'NULL') {
		return null;
	}

	switch (type) {
		case 'datetime':
		case 'timestamp':
			if (val == 'CURRENT_TIMESTAMP') {
				return val;
            } else if (val == '0000-00-00 00:00:00') {
                // HACK(arlen): Not sure if this is correct, but constructing
                // a Date out of this yields "Invalid Date".
                return null;
			} else {
				return new Date(val);
			}
		case 'text':
		case 'string':
			return val;
		case 'integer':
		case 'primary_key':
			return parseInt(val);
		case 'float':
			return parseFloat(val);
		case 'boolean':
			return (val == "TRUE");
		default:
			throw "Unknown friendly type `" + type + "`!";
	}
}
554775
def _sanitize_column(self, key, value, **kwargs):
        
        def sp_maker(x, index=None):
            return SparseArray(x, index=index,
                               fill_value=self._default_fill_value,
                               kind=self._default_kind)
        if isinstance(value, SparseSeries):
            clean = value.reindex(self.index).as_sparse_array(
                fill_value=self._default_fill_value, kind=self._default_kind)

        elif isinstance(value, SparseArray):
            if len(value) != len(self.index):
                raise ValueError('Length of values does not match '
                                 'length of index')
            clean = value

        elif hasattr(value, '__iter__'):
            if isinstance(value, Series):
                clean = value.reindex(self.index)
                if not isinstance(value, SparseSeries):
                    clean = sp_maker(clean)
            else:
                if len(value) != len(self.index):
                    raise ValueError('Length of values does not match '
                                     'length of index')
                clean = sp_maker(value)

        # Scalar
        else:
            clean = sp_maker(value, self.index)

        # always return a SparseArray!
        return clean
1192015
def convert_type(df, columns):
    
    # taken in part from the dplython package
    out_df = df.copy()
    for col in columns:
        column_values = pd.Series(out_df[col].unique())
        column_values = column_values[~column_values.isnull()]
        # empty
        if len(column_values) == 0:
            continue
        # boolean
        if set(column_values.values) < {'True', 'False'}:
            out_df[col] = out_df[col].map({'True': True, 'False': False})
            continue
        # numeric
        if pd.to_numeric(column_values, errors='coerce').isnull().sum() == 0:
            out_df[col] = pd.to_numeric(out_df[col], errors='ignore')
            continue
        # datetime
        if pd.to_datetime(column_values, errors='coerce').isnull().sum() == 0:
            out_df[col] = pd.to_datetime(out_df[col], errors='ignore',
                                         infer_datetime_format=True)
            continue

    return out_df
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;
    }
}
1270735
def to_datetime(self, column):
        '''
        
        '''
        if column in self:
            if self[column].dtype in NUMPY_NUMERICAL:
                self[column] = pd.to_datetime(self[column], unit='s')
            else:
                self[column] = pd.to_datetime(self[column], utc=True)
767638
def ColumnAttr(name='', attr=None, **kwargs):
    ''
    return Column(name,
                  expr=attr if attr is not None else name,
                  getter=lambda col,row: getattrdeep(row, col.expr),
                  setter=lambda col,row,val: setattrdeep(row, col.expr, val),
                  **kwargs)
273584
def parse_single_value(value):
    
    if isinstance(value, basestring):
        try:
            if value.startswith('"') and value.endswith('"'):
                value = str(value[1:-1])
            elif '.' in value:
                value = float(value)
            else:
                value = int(value)
        except ValueError:
            value = str(value)
    elif not isinstance(value, (int, float)):
        raise ArcanaUsageError(
            "Unrecognised type for single value {}".format(value))
    return value
196273
def python_cast(self, v):
        

        if self.type_is_time():
            dt = dateutil.parser.parse(v)

            if self.datatype == Column.DATATYPE_TIME:
                dt = dt.time()
            if not isinstance(dt, self.python_type):
                raise TypeError('{} was parsed to {}, expected {}'.format(v, type(dt), self.python_type))

            return dt
        else:
            # This isn't calling the python_type method -- it's getting a python type, then instantialting it,
            # such as "int(v)"
            return self.python_type(v)
967262
def _parse(partial_dt):
    
    dt = None
    try:
        if isinstance(partial_dt, datetime):
            dt = partial_dt
        if isinstance(partial_dt, date):
            dt = _combine_date_time(partial_dt, time(0, 0, 0))
        if isinstance(partial_dt, time):
            dt = _combine_date_time(date.today(), partial_dt)
        if isinstance(partial_dt, (int, float)):
            dt = datetime.fromtimestamp(partial_dt)
        if isinstance(partial_dt, (str, bytes)):
            dt = parser.parse(partial_dt, default=timezone.now())

        if dt is not None and timezone.is_naive(dt):
            dt = timezone.make_aware(dt)
        return dt
    except ValueError:
        return None
293776
def _parse_time(self, time):
        """"""
        if time is None:
            return None

        if isinstance(time, dict):
            if 'column' not in time:
                raise ValueError("`time` must include a 'column' key/value")
            time_column = time['column']
            time_options = time
        elif isinstance(time, str):
            time_column = time
            time_options = {}
        else:
            raise ValueError(
                '`time` should be a column name or dictionary of '
                'styling options.')

        self.style_cols[time_column] = None
        time = {
            'column': time_column,
            'method': 'count',
            'cumulative': False,
            'frames': 256,
            'duration': 30,
            'trails': 2,
        }
        time.update(time_options)
        return time
607700
def parseDate(dateString, strict=True):
    
    if (not strict) and (not dateString):
        return None

    if not isinstance(dateString, basestring):
        raise TypeError('%r is not a string' % dateString)

    return parser.parse(dateString)
559744
def _type_single(self, value, _type):
        '  '
        if value is None or _type in (None, NoneType):
            # don't convert null values
            # default type is the original type if none set
            pass
        elif isinstance(value, _type):  # or values already of correct type
            # normalize all dates to epochs
            value = dt2ts(value) if _type in [datetime, date] else value
        else:
            if _type in (datetime, date):
                # normalize all dates to epochs
                value = dt2ts(value)
            elif _type in (unicode, str):
                # make sure all string types are properly unicoded
                value = to_encoding(value)
            else:
                try:
                    value = _type(value)
                except Exception:
                    value = to_encoding(value)
                    logger.error("typecast failed: %s(value=%s)" % (
                        _type.__name__, value))
                    raise
        return value