MCPcopy Index your code
hub / github.com/javascriptdata/danfojs / getRowAndColValues

Method getRowAndColValues

src/danfojs-base/shared/utils.ts:180–193  ·  view source on GitHub ↗

* Retrieve row array and column names from an object of the form {a: [1,2,3,4], b: [30,20, 30, 20]} * @param obj The object to retrieve rows and column names from.

(obj: object)

Source from the content-addressed store, hash-verified

178 * @param obj The object to retrieve rows and column names from.
179 */
180 getRowAndColValues(obj: object): [ArrayType1D | ArrayType2D, string[]] {
181 const colNames = Object.keys(obj);
182 const colData = Object.values(obj);
183 const firstColLen = colData[0].length;
184
185 colData.forEach((cdata) => {
186 if (cdata.length != firstColLen) {
187 throw Error("Length Error: Length of columns must be the same!");
188 }
189 });
190
191 const rowsArr = this.transposeArray(colData)
192 return [rowsArr, colNames];
193 }
194
195 /**
196 * Converts a 2D array of array to 1D array for Series Class

Callers 3

utils.test.jsFile · 0.80
loadObjectIntoNdframeMethod · 0.80
utils.test.tsFile · 0.80

Calls 2

transposeArrayMethod · 0.95
valuesMethod · 0.65

Tested by

no test coverage detected