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

Method transposeArray

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

* Transposes an array of array * @param obj The object to check. * @param key The key to find.

(arr: ArrayType1D | ArrayType2D)

Source from the content-addressed store, hash-verified

152 * @param key The key to find.
153 */
154 transposeArray(arr: ArrayType1D | ArrayType2D): ArrayType1D | ArrayType2D { //old name: __get_col_values
155 if (arr.length === 0) return arr
156
157 const rowLen: number = arr.length;
158 if (Array.isArray(arr[0])) {
159 const colLen: number = arr[0].length;
160 const newArr = [];
161
162 for (let i = 0; i <= colLen - 1; i++) {
163 const temp = [];
164 for (let j = 0; j < rowLen; j++) {
165 const _elem = (arr as any)[j][i]
166 temp.push(_elem);
167 }
168 newArr.push(temp);
169 }
170 return newArr;
171 } else {
172 return arr;
173 }
174 }
175
176 /**
177 * Retrieve row array and column names from an object of the form {a: [1,2,3,4], b: [30,20, 30, 20]}

Callers 12

getRowAndColValuesMethod · 0.95
inferDtypeMethod · 0.95
utils.test.jsFile · 0.80
$getDataArraysByAxisMethod · 0.80
cumOpsMethod · 0.80
dropNaMethod · 0.80
transposeMethod · 0.80
TMethod · 0.80
loadArrayIntoNdframeMethod · 0.80
$setValuesMethod · 0.80
getColumnDataMethod · 0.80
utils.test.tsFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected