* Internal function to format and load a Javascript object or object of arrays into NDFrame. * @param data Object or object of arrays. * @param type The type of the object. There are two recognized types: * * - type 1 object are in JSON format `[{a: 1, b: 2}, {a: 30, b: 20}]`.
({ data, type, index, columns, dtypes }: LoadObjectDataType)
| 132 | * @param dtypes Array of data types for each the column. |
| 133 | */ |
| 134 | private loadObjectIntoNdframe({ data, type, index, columns, dtypes }: LoadObjectDataType): void { |
| 135 | if (type === 1 && Array.isArray(data)) { |
| 136 | const _data = (data).map((item) => { |
| 137 | return Object.values(item); |
| 138 | }); |
| 139 | |
| 140 | let _columnNames; |
| 141 | |
| 142 | if (columns) { |
| 143 | _columnNames = columns |
| 144 | } else { |
| 145 | _columnNames = Object.keys((data)[0]); |
| 146 | } |
| 147 | |
| 148 | this.loadArrayIntoNdframe({ data: _data, index, columns: _columnNames, dtypes }); |
| 149 | |
| 150 | } else { |
| 151 | const [_data, _colNames] = utils.getRowAndColValues(data); |
| 152 | let _columnNames; |
| 153 | |
| 154 | if (columns) { |
| 155 | _columnNames = columns |
| 156 | } else { |
| 157 | _columnNames = _colNames |
| 158 | } |
| 159 | this.loadArrayIntoNdframe({ data: _data, index, columns: _columnNames, dtypes }); |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | /** |
| 164 | * Converts and returns the data in the NDframe as a Tensorflow.js Tensor. |
no test coverage detected