Transform dataframe into a numpy ndarray(matrix)
161360
def transform(self, df):
        """"""

        # Make sure the dataframe columns are the same as the ones passed to fit
        assert df.columns.equals(self.columns_)

        # Convert the dataframe with get_dummies
        df_with_dummies = pd.get_dummies(df)

        # Make sure our columns exactly match what we stored during the fit operation
        my_columns = set(df_with_dummies.columns.tolist())
        output_column_set = set(self.columns_in_order)
        for column in my_columns.difference(output_column_set):
            print('Deleting extra column {:s}'.format(column))
            del df_with_dummies[column]
        for column in output_column_set.difference(my_columns):
            print('Adding column {:s}'.format(column))
            df_with_dummies[column] = 0

        # Returns the same columns in the same order every time
        return np.asarray(df_with_dummies[self.columns_in_order])
578267
def convert_data_to_ndarray(self):
        """"""
        if self._data_structure != "DataFrame":
            raise Exception(f"Data is not a DataFrame but {self._data_structure}.")
        self._data = self._convert_to_ndarray(self._data)
        self._update_data_structure()
        return self
1353248
def clean_dataframe(df):
    """"""
    df = df.fillna(method='ffill')
    df = df.fillna(0.0)
    return df
897327
def _index_into(self, idx, data):
        
        try:
            if is_dataframe(data):
                # Assume column indexing
                return data[idx]
            # Otherwise assume numpy array-like indexing
            return data[:,idx]
        except Exception as e:
            raise IndexError(
                "could not index column '{}' into type {}: {}".format(
                    self.columns, data.__class__.__name__, e
            ))
197580
def from_dataframe(dataframe, table_name=""):
        

        return TableData(table_name, list(dataframe.columns.values), dataframe.values.tolist())
799295
def to_chunks(self, df, **kwargs):
        
        if len(df) > 0:
            yield b'NA', b'NA', b'NA', df
1186195
def to_arrays(data, columns, coerce_float=False, dtype=None):
    
    if isinstance(data, ABCDataFrame):
        if columns is not None:
            arrays = [data._ixs(i, axis=1).values
                      for i, col in enumerate(data.columns) if col in columns]
        else:
            columns = data.columns
            arrays = [data._ixs(i, axis=1).values for i in range(len(columns))]

        return arrays, columns

    if not len(data):
        if isinstance(data, np.ndarray):
            columns = data.dtype.names
            if columns is not None:
                return [[]] * len(columns), columns
        return [], []  # columns if columns is not None else []
    if isinstance(data[0], (list, tuple)):
        return _list_to_arrays(data, columns, coerce_float=coerce_float,
                               dtype=dtype)
    elif isinstance(data[0], abc.Mapping):
        return _list_of_dict_to_arrays(data, columns,
                                       coerce_float=coerce_float, dtype=dtype)
    elif isinstance(data[0], ABCSeries):
        return _list_of_series_to_arrays(data, columns,
                                         coerce_float=coerce_float,
                                         dtype=dtype)
    elif isinstance(data[0], Categorical):
        if columns is None:
            columns = ibase.default_index(len(data))
        return data, columns
    elif (isinstance(data, (np.ndarray, ABCSeries, Index)) and
          data.dtype.names is not None):

        columns = list(data.dtype.names)
        arrays = [data[k] for k in columns]
        return arrays, columns
    else:
        # last ditch effort
        data = lmap(tuple, data)
        return _list_to_arrays(data, columns, coerce_float=coerce_float,
                               dtype=dtype)
896113
def convert_sparse_to_dataframe(spark, context, sparse_matrix):
    
    m = sparse_matrix.tocoo()
    data = context.parallelize(numpy.array([m.row, m.col, m.data]).T,
                               numSlices=len(m.row)/1024)
    return spark.createDataFrame(data.map(lambda p: Row(row=int(p[0]),
                                                        col=int(p[1]),
                                                        data=float(p[2]))))
309571
def transform_array_to_list(array):
    ''' 

    '''
    if (array.dtype.kind in ('u', 'i', 'f') and (~np.isfinite(array)).any()):
        transformed = array.astype('object')
        transformed[np.isnan(array)] = 'NaN'
        transformed[np.isposinf(array)] = 'Infinity'
        transformed[np.isneginf(array)] = '-Infinity'
        return transformed.tolist()
    elif (array.dtype.kind == 'O' and pd and pd.isnull(array).any()):
        transformed = array.astype('object')
        transformed[pd.isnull(array)] = 'NaN'
        return transformed.tolist()
    return array.tolist()
281916
def to_dataframe(self):
        
        keys = self.data[0].keys()
        column_list =[]
        for k in keys:
            key_list = []
            for i in xrange(0,len(self.data)):
                key_list.append(self.data[i][k])
            column_list.append(key_list)
        df = DataFrame(np.asarray(column_list).transpose(), columns=keys)
        for i in xrange(0,df.shape[1]):
            if is_number(df.iloc[:,i]):
                df.iloc[:,i] = df.iloc[:,i].astype(float)
        return df
956708
def _dataframe_to_vertex_list(df):
    
    cols = df.columns
    if len(cols):
        assert _VID_COLUMN in cols, "Vertex DataFrame must contain column %s" % _VID_COLUMN
        df = df[cols].T
        ret = [Vertex(None, _series=df[col]) for col in df]
        return ret
    else:
        return []
1078784
function toArray(matrix, array) {
  for (var i = 0, l = matrix.length; i < l; i++) {
    array[i] = matrix[i];
  }

  return array;
}
204644
def _numpy_to_values(data):
        ''''''
        def to_list_no_index(xvals, yvals):
            return [{"x": x, "y": np.asscalar(y)}
                    for x, y in zip(xvals, yvals)]

        if len(data.shape) == 1 or data.shape[1] == 1:
            xvals = range(data.shape[0] + 1)
            values = to_list_no_index(xvals, data)
        elif len(data.shape) == 2:
            if data.shape[1] == 2:
                # NumPy arrays and matrices have different iteration rules.
                if isinstance(data, np.matrix):
                    xidx = (0, 0)
                    yidx = (0, 1)
                else:
                    xidx = 0
                    yidx = 1

                xvals = [np.asscalar(row[xidx]) for row in data]
                yvals = [np.asscalar(row[yidx]) for row in data]
                values = [{"x": x, "y": y} for x, y in zip(xvals, yvals)]
            else:
                raise ValueError('arrays with > 2 columns not supported')
        else:
            raise ValueError('invalid dimensions for ndarray')

        return values
705231
def arrays_to_mgr(arrays, arr_names, index, columns, dtype=None):
    
    # figure out the index, if necessary
    if index is None:
        index = extract_index(arrays)
    else:
        index = ensure_index(index)

    # don't force copy because getting jammed in an ndarray anyway
    arrays = _homogenize(arrays, index, dtype)

    # from BlockManager perspective
    axes = [ensure_index(columns), index]

    return create_block_manager_from_arrays(arrays, arr_names, axes)
905914
def convert_tokens_into_matrix(self, token_list):
        '''
        
        '''
        return np.array(self.vectorize(token_list)).astype(np.float32)
733871
def __make_matrix(self, n, val):
        """"""
        matrix = []
        for i in range(n):
            matrix += [[val for j in range(n)]]
        return matrix
528216
def fit_transform(self, input_df, normalize=True):
        
        # Shallow copy the dataframe (we'll be making changes to some columns)
        _df = input_df.copy(deep=False)

        # Set class variables that will be used both now and later for transform
        self.normalize = normalize

        # Convert columns that are probably categorical
        self.convert_to_categorical(_df)

        # First check for columns that are explicitly categorical
        self.cat_columns = _df.select_dtypes(include=['category']).columns.tolist()

        # Remove any columns that aren't bool/int/float/category
        _df = _df.select_dtypes(include=['bool', 'int', 'float', 'category'])

        # Normalize any numeric columns if normalize specified
        if self.normalize:
            for column in list(_df.select_dtypes(include=[np.number]).columns.values):
                print('Normalizing column {:s}...'.format(column))
                _df[column], _min, _max = self._normalize_series(_df[column])
                self.norm_map[column] = (_min, _max)

        # Now that categorical columns are setup call the dummy_encoder
        return self.dummy_encoder.fit_transform(_df)