MCPcopy Index your code
hub / github.com/javascriptdata/danfojs / $setValues

Method $setValues

src/danfojs-base/core/generic.ts:372–407  ·  view source on GitHub ↗

* Updates the internal $data property to the specified value * @param values An array of values to set * @param checkLength Whether to check the length of the new values and the existing row length * @param checkColumnLength Whether to check the length of the new values and the existi

(values: ArrayType1D | ArrayType2D, checkLength: boolean = true, checkColumnLength: boolean = true)

Source from the content-addressed store, hash-verified

370 * @param checkColumnLength Whether to check the length of the new values and the existing column length
371 * */
372 $setValues(values: ArrayType1D | ArrayType2D, checkLength: boolean = true, checkColumnLength: boolean = true): void {
373 if (this.$isSeries) {
374 if (checkLength && values.length != this.shape[0]) {
375 ErrorThrower.throwRowLengthError(this, values.length)
376 }
377
378 this.$data = values
379 this.$dtypes = utils.inferDtype(values) //Dtype may change depeneding on the value set
380
381 if (!this.$config.isLowMemoryMode) {
382 this.$dataIncolumnFormat = values
383 }
384
385 } else {
386 if (checkLength && values.length != this.shape[0]) {
387 ErrorThrower.throwRowLengthError(this, values.length)
388 }
389
390 if (checkColumnLength) {
391 values.forEach(value => {
392 if ((value as ArrayType1D).length != this.shape[1]) {
393 ErrorThrower.throwColumnLengthError(this, values.length)
394 }
395 })
396 }
397
398 this.$data = values
399 this.$dtypes = utils.inferDtype(values)
400
401 if (!this.$config.isLowMemoryMode) {
402 this.$dataIncolumnFormat = utils.transposeArray(values)
403 }
404
405 }
406
407 }
408
409 /**
410 * Returns the underlying data in Array column format.

Callers 15

generic.test.jsFile · 0.80
$MathOpsMethod · 0.80
absMethod · 0.80
roundMethod · 0.80
cumOpsMethod · 0.80
dropNaMethod · 0.80
addColumnMethod · 0.80
fillNaMethod · 0.80
dropMethod · 0.80
sortValuesMethod · 0.80
setIndexMethod · 0.80
applyMapMethod · 0.80

Calls 2

inferDtypeMethod · 0.80
transposeArrayMethod · 0.80

Tested by

no test coverage detected