Encode columns so their values are usable in vector operations. Making a few 
    assumptions here, like that datetime should be an integer, and that it's 
    acceptable to fill NaNs with 0.
354642
def encode_df(df, data_types={}):
    

    numbers = []
    categories = []
    datetimes = []
        
    for column, series in df.iteritems():
        if column in data_types:
            dtypes = data_types[column]
        else:
            dtypes = {}
        
        if 'datetime' in dtypes:
            index = pd.DatetimeIndex(pd.to_datetime(series.values))
            df[column] = index.astype(np.int64).astype(float)
            datetimes.append(column)
            
        elif any([dtype in dtypes for dtype in ['category', 'label']]):
            # If this can be treated as a category, encode it
            df = pd.get_dummies(df,columns=[column])
            categories.append(column)
                    
        elif 'numeric' in dtypes:
            df[column] = clean_numbers(df[column].values)
            df[column] = df[column].astype(float)
            numbers.append(column)
            
        else:
            df.drop(column,1,inplace=True)

    # Scale continuous columns
    scaler = MinMaxScaler()
    df[numbers + datetimes] = scaler.fit_transform(df[numbers + datetimes])
    
    return df, categories, numbers, datetimes
1093012
def _transform_col(self, x, i):
        
        return x.fillna(NAN_INT).map(self.label_encoders[i]).fillna(0)
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());
				}
			}
		}
	}
805133
function encodeString(string) {
	//it actually accepts any kind of object as input
	if (string === null) {
		return values.NULL;
	} else if (string === "") {
		return values.EMPTY;
	} else {//0 false undefined NaN will pass from here
		return encodeURIComponent(string)
		.replace(/%20/g, "+");
	}
}
502446
function encodeArray( encoder, data ) {
	encoder.log(LOG.PRM, "array, len="+data.length+", peek="+data[0]);
	
	// Check for empty array
	if (data.length === 0) {
		encodeArray_EMPTY( encoder );
		return;
	}

	// Get typed array typed
	var tt = getTypedArrayType(data);

	// Check for numerical array
	if ( tt <= NUMTYPE.NUMERIC ) {
		encodeArray_Numeric( encoder, data, tt );
	} else {
		encodeArray_Primitive( encoder, data );
	}

}
774858
def fromNumpy(cls, data):
        
        assert np is not None
        if isinstance(data, np.ndarray):
            index = []
            if len(data.shape) == 1:
                columns = [('value', data.tolist())]
            elif len(data.shape) == 2:
                columns = [
                    ('c{}'.format(i), col)
                    for i, col in enumerate(zip(*data.tolist()))
                ]
            else:
                raise TypeError
        else:
            raise TypeError
        return cls(index=index, columns=columns)
717086
def _set_noconvert_columns(self):
        
        names = self.orig_names
        if self.usecols_dtype == 'integer':
            # A set of integers will be converted to a list in
            # the correct order every single time.
            usecols = list(self.usecols)
            usecols.sort()
        elif (callable(self.usecols) or
                self.usecols_dtype not in ('empty', None)):
            # The names attribute should have the correct columns
            # in the proper order for indexing with parse_dates.
            usecols = self.names[:]
        else:
            # Usecols is empty.
            usecols = None

        def _set(x):
            if usecols is not None and is_integer(x):
                x = usecols[x]

            if not is_integer(x):
                x = names.index(x)

            self._reader.set_noconvert(x)

        if isinstance(self.parse_dates, list):
            for val in self.parse_dates:
                if isinstance(val, list):
                    for k in val:
                        _set(k)
                else:
                    _set(val)

        elif isinstance(self.parse_dates, dict):
            for val in self.parse_dates.values():
                if isinstance(val, list):
                    for k in val:
                        _set(k)
                else:
                    _set(val)

        elif self.parse_dates:
            if isinstance(self.index_col, list):
                for k in self.index_col:
                    _set(k)
            elif self.index_col is not None:
                _set(self.index_col)
763755
def decode_timeseries_row(self, tsrow, tscols=None,
                              convert_timestamp=False):
        
        row = []
        for i, cell in enumerate(tsrow.cells):
            col = None
            if tscols is not None:
                col = tscols[i]
            if cell.HasField('varchar_value'):
                if col and not (col.type == TsColumnType.Value('VARCHAR') or
                                col.type == TsColumnType.Value('BLOB')):
                    raise TypeError('expected VARCHAR or BLOB column')
                else:
                    row.append(cell.varchar_value)
            elif cell.HasField('sint64_value'):
                if col and col.type != TsColumnType.Value('SINT64'):
                    raise TypeError('expected SINT64 column')
                else:
                    row.append(cell.sint64_value)
            elif cell.HasField('double_value'):
                if col and col.type != TsColumnType.Value('DOUBLE'):
                    raise TypeError('expected DOUBLE column')
                else:
                    row.append(cell.double_value)
            elif cell.HasField('timestamp_value'):
                if col and col.type != TsColumnType.Value('TIMESTAMP'):
                    raise TypeError('expected TIMESTAMP column')
                else:
                    dt = cell.timestamp_value
                    if convert_timestamp:
                        dt = datetime_from_unix_time_millis(
                            cell.timestamp_value)
                    row.append(dt)
            elif cell.HasField('boolean_value'):
                if col and col.type != TsColumnType.Value('BOOLEAN'):
                    raise TypeError('expected BOOLEAN column')
                else:
                    row.append(cell.boolean_value)
            else:
                row.append(None)
        return row
614172
function serializeValue(value) {

    var type;
    if ( _.isNull(value) ) {
        type = ColumnType.Object;
    } else if ( _.isNumber(value) ) {
        type = ColumnType.Real;
    } else if ( _.isDate(value) ) {
        type = ColumnType.Date;
    } else if ( _.isBool(value) ) {
        type = ColumnType.Boolean;
    } else if ( _.isString(value) ) {
        type = ColumnType.String;
    } else if ( _.isArray(value) ) {
        type = ColumnType.Array;
    } else if ( _.isObject(value) ) {
        type = ColumnType.Object;
    } else {
        type = ColumnType.Object;
    }

    return serializeMember(value, type);
}
189596
def safe_datetime_cast(self, col):
        
        casted_dates = pd.to_datetime(col[self.col_name], format=self.date_format, errors='coerce')

        if len(casted_dates[casted_dates.isnull()]):
            # This will raise an error for bad formatted data
            # but not for out of bonds or missing dates.
            slice_ = casted_dates.isnull() & ~col[self.col_name].isnull()
            col[slice_][self.col_name].apply(self.strptime_format)

        return casted_dates
1032632
def fillNoneValues(column):
    
    if column.dtype == object:
        column.fillna('', inplace=True)
    return column
1076292
def _replace_nans(self, data):
        # return data
        """"""
        for c in data:
            dtype = data[c].dtype
            if dtype in (np.float32, np.float64):
                if dtype == np.float32:
                    replacement = self.MISSING_VALUES['f']
                else:
                    replacement = self.MISSING_VALUES['d']
                data[c] = data[c].fillna(replacement)

        return data
513951
def encode_timeseries_put(self, tsobj):
        '''
        
        '''
        if tsobj.columns:
            raise NotImplementedError('columns are not used')

        if tsobj.rows and isinstance(tsobj.rows, list):
            req_rows = []
            for row in tsobj.rows:
                req_r = []
                for cell in row:
                    req_r.append(self.encode_to_ts_cell(cell))
                req_rows.append(tuple(req_r))
            req = tsputreq_a, tsobj.table.name, [], req_rows
            mc = MSG_CODE_TS_TTB_MSG
            rc = MSG_CODE_TS_TTB_MSG
            return Msg(mc, encode(req), rc)
        else:
            raise RiakError("TsObject requires a list of rows")
1063071
def _prep_datum(self, datum, dialect, col, needs_conversion):
        """"""
        if datum is None or (needs_conversion and not str(datum).strip()):
            return 'NULL'
        pytype = self.columns[col]['pytype']

        if needs_conversion:
            if pytype == datetime.datetime:
                datum = dateutil.parser.parse(datum)
            elif pytype == bool:
                datum = th.coerce_to_specific(datum)
                if dialect.startswith('sqlite'):
                    datum = 1 if datum else 0
            else:
                datum = pytype(str(datum))

        if isinstance(datum, datetime.datetime) or isinstance(datum, datetime.date):
            if dialect in self._datetime_format:
                return datum.strftime(self._datetime_format[dialect])
            else:
                return "'%s'" % datum
        elif hasattr(datum, 'lower'):
            # simple SQL injection protection, sort of... ?
            return "'%s'" % datum.replace("'", "''")
        else:
            return datum
747003
def values(self, dtype, dates, sids):
        
        shape = (len(dates), len(sids))
        return {
            datetime64ns_dtype: self._datetime_values,
            float64_dtype: self._float_values,
            int64_dtype: self._int_values,
            bool_dtype: self._bool_values,
            object_dtype: self._object_values,
        }[dtype](shape)
203352
def _transform_col(self, x, i):
        
        return x.fillna(NAN_INT).map(self.target_encoders[i]).fillna(self.target_mean)
18985
def coerce_to_dtype(dtype, value):
    
    name = dtype.name
    if name.startswith('datetime64'):
        if name == 'datetime64[D]':
            return make_datetime64D(value)
        elif name == 'datetime64[ns]':
            return make_datetime64ns(value)
        else:
            raise TypeError(
                "Don't know how to coerce values of dtype %s" % dtype
            )
    return dtype.type(value)